From 5d669b13cca629ddbfb50c0b6edb9a26083204fd Mon Sep 17 00:00:00 2001 From: Maurilio Longo Date: Tue, 28 Aug 2001 17:25:33 +0000 Subject: [PATCH] 2001-08-28 19:21 GMT+2 Maurilio Longo * contrib/os2pm/*.* * changes to every file to add menu creation capabilities --- harbour/ChangeLog | 4 +++ harbour/contrib/os2pm/os2pm.c | 55 +++++++++++++++++++++--------- harbour/contrib/os2pm/os2pm.ch | 49 +++++++++++++------------- harbour/contrib/os2pm/tform.prg | 4 +-- harbour/contrib/os2pm/tmenu.prg | 14 +++++--- harbour/contrib/os2pm/tmenuitm.prg | 40 +++++++++++++++++----- 6 files changed, 111 insertions(+), 55 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 7ceb0d0246..2d8259a058 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,7 @@ +2001-08-28 19:21 GMT+2 Maurilio Longo + * contrib/os2pm/*.* + * changes to every file to add menu creation capabilities + 2001-08-27 20:50 GMT -3 Luiz Rafael Culik *utils/hbmake/hbmake.prg * Fixes related to path finding to Apps(C compiler and harbour.exe) diff --git a/harbour/contrib/os2pm/os2pm.c b/harbour/contrib/os2pm/os2pm.c index dfdb609550..be3b3af2e9 100644 --- a/harbour/contrib/os2pm/os2pm.c +++ b/harbour/contrib/os2pm/os2pm.c @@ -56,9 +56,8 @@ #define INCL_BASE #define INCL_PM - - #include + #include "hbapi.h" @@ -68,13 +67,33 @@ HAB hb_pm_GetHab( void ); HB_FUNC( WINREGISTERCLASS ) { - hb_retl( WinRegisterClass( hb_pm_GetHab(), /* anchor block handle */ - hb_parc( 1 ), /* Class Name */ - ( PFNWP ) WinDefWindowProc, /* default Class procedure */ - hb_parnl( 2 ), /* style */ - hb_parnl( 3 ) ) ); /* extra bytes */ + hb_retl( WinRegisterClass( hb_pm_GetHab(), /* anchor block handle */ + hb_parc( 1 ), /* Class Name */ + ( PFNWP ) WinDefWindowProc, /* default Class procedure */ + hb_parnl( 2 ), /* style */ + hb_parnl( 3 ) ) ); /* extra bytes */ } + +HB_FUNC(WINCREATEWINDOW) +{ + hb_retnl((LONG) WinCreateWindow( (HWND) hb_parnl(1), /* hWnd parent */ + (PCSZ) hb_parc(2), /* pszClass */ + (PCSZ) hb_parc(3), /* pszName */ + (ULONG) hb_parnl(4), /* flStyle */ + (LONG) hb_parnl(5), /* x */ + (LONG) hb_parnl(6), /* y */ + (LONG) hb_parnl(7), /* cx */ + (LONG) hb_parnl(8), /* cy */ + (HWND) hb_parnl(9), /* hwndOwner */ + (HWND) hb_parnl(10), /* hwndInsertBehind */ + (ULONG) hb_parnl(11), /* id */ + (PVOID) hb_parnl(12), /* pCtlData, */ + (PVOID) hb_parnl(13))); /* pPresParams */ + +} + + HB_FUNC( WINCREATESTDWINDOW ) { ULONG lFrame = hb_parnl( 3 ); @@ -82,18 +101,19 @@ HB_FUNC( WINCREATESTDWINDOW ) hb_retnl( ( LONG ) hWndFrame = WinCreateStdWindow( ( HWND ) hb_parnl( 1 ), /* hWndParent */ - hb_parnl( 2 ), /* style */ - &lFrame, /* lFrame */ - hb_parc( 4 ), /* cClassName */ - hb_parc( 5 ), /* cCaption */ - hb_parnl( 6 ), /* lStyleClient */ - hb_parnl( 7 ), /* hModule */ - hb_parnl( 8 ), /* nId */ - ( PHWND ) &hWndClient ) ); /* Window client handle */ + hb_parnl( 2 ), /* style */ + &lFrame, /* lFrame */ + hb_parc( 4 ), /* cClassName */ + hb_parc( 5 ), /* cCaption */ + hb_parnl( 6 ), /* lStyleClient */ + hb_parnl( 7 ), /* hModule */ + hb_parnl( 8 ), /* nId */ + ( PHWND ) &hWndClient ) ); /* Window client handle */ hb_stornl( ( LONG ) hWndClient, 9 ); } + HB_FUNC( HB_PM_SHOWMODAL ) { QMSG qmsg; @@ -105,8 +125,8 @@ HB_FUNC( HB_PM_SHOWMODAL ) } } -/* nOr() is a very used function */ +/* nOr() is a very used function */ HB_FUNC( NOR ) { LONG lRet = 0; @@ -161,7 +181,8 @@ HB_FUNC( GETHAB ) HB_FUNC( WINCREATEMENU ) { hb_retnl( ( LONG ) WinCreateMenu( ( HWND ) hb_parnl( 1 ), - ( PVOID ) hb_parnl( 2 ) ) ); + (PVOID) NULL /*( PVOID ) hb_parnl( 2 )*/ ) ); + } diff --git a/harbour/contrib/os2pm/os2pm.ch b/harbour/contrib/os2pm/os2pm.ch index c9751df572..f0ef744060 100644 --- a/harbour/contrib/os2pm/os2pm.ch +++ b/harbour/contrib/os2pm/os2pm.ch @@ -1827,30 +1827,31 @@ #define CTLS_WM_BIDI_LAST 0x39f #define WM_DBCSFIRST 0x00b0 #define WM_DBCSLAST 0x00cf -#define WC_FRAME ((PSZ)0xffff0001) -#define WC_COMBOBOX ((PSZ)0xffff0002) -#define WC_BUTTON ((PSZ)0xffff0003) -#define WC_MENU ((PSZ)0xffff0004) -#define WC_STATIC ((PSZ)0xffff0005) -#define WC_ENTRYFIELD ((PSZ)0xffff0006) -#define WC_LISTBOX ((PSZ)0xffff0007) -#define WC_SCROLLBAR ((PSZ)0xffff0008) -#define WC_TITLEBAR ((PSZ)0xffff0009) -#define WC_MLE ((PSZ)0xffff000a) -#define WC_APPSTAT ((PSZ)0xffff0010) -#define WC_KBDSTAT ((PSZ)0xffff0011) -#define WC_PECIC ((PSZ)0xffff0012) -#define WC_DBE_KKPOPUP ((PSZ)0xffff0013) -#define WC_SPINBUTTON ((PSZ)0xffff0020) -#define WC_CONTAINER ((PSZ)0xffff0025) -#define WC_SLIDER ((PSZ)0xffff0026) -#define WC_VALUESET ((PSZ)0xffff0027) -#define WC_NOTEBOOK ((PSZ)0xffff0028) -#define WC_PENFIRST ((PSZ)0xffff0029) -#define WC_PENLAST ((PSZ)0xffff002c) -#define WC_MMPMFIRST ((PSZ)0xffff0040) -#define WC_CIRCULARSLIDER ((PSZ)0xffff0041) -#define WC_MMPMLAST ((PSZ)0xffff004f) + +#define WC_FRAME 0xffff0001 +#define WC_COMBOBOX 0xffff0002 +#define WC_BUTTON 0xffff0003 +#define WC_MENU 0xffff0004 +#define WC_STATIC 0xffff0005 +#define WC_ENTRYFIELD 0xffff0006 +#define WC_LISTBOX 0xffff0007 +#define WC_SCROLLBAR 0xffff0008 +#define WC_TITLEBAR 0xffff0009 +#define WC_MLE 0xffff000a +#define WC_APPSTAT 0xffff0010 +#define WC_KBDSTAT 0xffff0011 +#define WC_PECIC 0xffff0012 +#define WC_DBE_KKPOPUP 0xffff0013 +#define WC_SPINBUTTON 0xffff0020 +#define WC_CONTAINER 0xffff0025 +#define WC_SLIDER 0xffff0026 +#define WC_VALUESET 0xffff0027 +#define WC_NOTEBOOK 0xffff0028 +#define WC_PENFIRST 0xffff0029 +#define WC_PENLAST 0xffff002c +#define WC_MMPMFIRST 0xffff0040 +#define WC_CIRCULARSLIDER 0xffff0041 +#define WC_MMPMLAST 0xffff004f #define WS_VISIBLE 0x80000000 #define WS_DISABLED 0x40000000 diff --git a/harbour/contrib/os2pm/tform.prg b/harbour/contrib/os2pm/tform.prg index ff05661229..04e2832675 100644 --- a/harbour/contrib/os2pm/tform.prg +++ b/harbour/contrib/os2pm/tform.prg @@ -60,14 +60,14 @@ CLASS TForm DATA hWnd - DATA oMainMenu + DATA oMainMenu CLASSDATA lRegistered METHOD New() METHOD ShowModal() - METHOD cCaption() INLINE WinGetText( ::hWnd ) + METHOD cCaption() INLINE WinGetText( ::hWnd ) METHOD _cCaption( cNewCaption ) INLINE ; WinSetWindowText( ::hWnd, cNewCaption ) diff --git a/harbour/contrib/os2pm/tmenu.prg b/harbour/contrib/os2pm/tmenu.prg index 72e1ff45ed..a4b82bc324 100644 --- a/harbour/contrib/os2pm/tmenu.prg +++ b/harbour/contrib/os2pm/tmenu.prg @@ -54,17 +54,20 @@ #include "hbclass.ch" +#include "os2pm.ch" + CLASS TMenu - DATA nHandle - DATA aItems + DATA nHandle // Handle of this SUBMENU (be it top level or drop down) + DATA aItems // Items inside this menu METHOD New( oForm ) METHOD Add( oMenuItem ) ENDCLASS + METHOD New( oForm ) CLASS TMenu ::aItems = {} @@ -72,11 +75,14 @@ METHOD New( oForm ) CLASS TMenu return Self + METHOD Add( oMenuItem ) CLASS TMenu - WinAddMenuItem( ::nHandle, oMenuItem:cCaption, Len( ::aItems ),; - nil, oMenuItem:nId, oMenuItem:lActive ) + WinAddMenuItem( ::nHandle, oMenuItem:cCaption, MIT_END,; + oMenuItem:nHandle, oMenuItem:nId, oMenuItem:lEnabled ) AAdd( ::aItems, oMenuItem ) return nil + + diff --git a/harbour/contrib/os2pm/tmenuitm.prg b/harbour/contrib/os2pm/tmenuitm.prg index bfa621c9d3..9b9f439c90 100644 --- a/harbour/contrib/os2pm/tmenuitm.prg +++ b/harbour/contrib/os2pm/tmenuitm.prg @@ -55,26 +55,50 @@ #include "common.ch" #include "hbclass.ch" +#include "os2pm.ch" + CLASS TMenuItem - DATA cCaption - DATA cAction - DATA nId - DATA lActive + DATA cCaption // Specifies the text of the menu item + DATA OnClick // A character description of the method to invoke + DATA nId // Command value to send to the container form + DATA lEnabled // Specifies whether the menu item is enabled - CLASSDATA nIdStart + DATA aItems // Contains the menu items in the submenu of the menu item + DATA oParent // Identifies the parent menu item of this menu item + DATA nHandle // The handle of _this_ menu item - METHOD New() + CLASSDATA nIdStart // start value for commands value to assign to menu items + + METHOD New( oOwner ) // Creates a new menu item + METHOD Add( oMenuItem ) // Adds a new drop down menu item ENDCLASS -METHOD New() CLASS TMenuItem + +METHOD New( oOwner ) CLASS TMenuItem DEFAULT ::nIdStart TO 110 ::cCaption = "" ::nId = ::nIdStart++ - ::lActive = .t. + ::lEnabled = .t. + ::oParent = oOwner + ::nHandle := WinCreateMenu( ::oParent:nHandle ) + ::aItems := {} return Self + + +METHOD Add( oMenuItem ) CLASS TMenuItem + + WinAddMenuItem( ::nHandle, oMenuItem:cCaption, MIT_END,; + nil, oMenuItem:nId, oMenuItem:lEnabled ) + + AAdd( ::aItems, oMenuItem ) + +return nil + + +