diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 091d891f8e..4a272b3896 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,7 +1,12 @@ +2001-09-04 08:41 GMT+2 Maurilio Longo + * contrib/hgf/os2pm/* + ! fixed menu items handling under OS/2 where you cannot change a MIS_TEXT into + a MIS_SUBMENU without first deleting MIS_TEXT and then inserting MIS_SUBMENU + 2001-09-03 17:19 GMT Dave Pearson * source/rtl/Makefile * Added persist.org to PRG_SOURCES. - + 2001-09-03 16:56 GMT Dave Pearson * source/rtl/isprint.c * Added missing comment close. diff --git a/harbour/contrib/hgf/os2pm/os2pm.c b/harbour/contrib/hgf/os2pm/os2pm.c index 7bf8228c02..3954ae8956 100644 --- a/harbour/contrib/hgf/os2pm/os2pm.c +++ b/harbour/contrib/hgf/os2pm/os2pm.c @@ -226,6 +226,30 @@ HB_FUNC( WINADDMENUITEM ) } +// Given an id of a menuitem changes it to a MIS_SUBMENU type of menu item +// NOTE: You have to delete and reinsert a menu item if you want to change it from +// a MIS_TEXT to a MIS_SUBMENU type of menuitem +HB_FUNC( WINMAKESUBMENUITEM ) +{ + MENUITEM mit; + MRESULT rc; + char text[100]; + + rc = WinSendMsg((HWND) hb_parnl(1), MM_QUERYITEM, MPFROM2SHORT(hb_parni(2), FALSE ), &mit ); + if ((BOOL)rc) { + WinSendMsg((HWND) hb_parnl(1), MM_QUERYITEMTEXT, MPFROM2SHORT(hb_parni(2), 100), &text ); + WinSendMsg((HWND) hb_parnl(1), MM_DELETEITEM, MPFROM2SHORT(hb_parni(2), FALSE ), 0L ); + + mit.hwndSubMenu = hb_parnl(3); + mit.afStyle |= MIS_SUBMENU; + + // re-insert the menuitem + WinSendMsg((HWND) hb_parnl(1), MM_INSERTITEM, &mit, &text); + } + hb_retnl(0); +} + + HB_FUNC( WINSETPARENT ) { hb_retl( WinSetParent( ( HWND ) hb_parnl( 1 ), ( HWND ) hb_parnl( 2 ), diff --git a/harbour/contrib/hgf/os2pm/tform.prg b/harbour/contrib/hgf/os2pm/tform.prg index ee7dfd6579..57da49b49f 100644 --- a/harbour/contrib/hgf/os2pm/tform.prg +++ b/harbour/contrib/hgf/os2pm/tform.prg @@ -78,7 +78,6 @@ CLASS TForm ASSIGN nWidth( nNewWidth ) INLINE ; WinSetWidth( ::hWnd, nNewWidth ) - ENDCLASS @@ -122,7 +121,7 @@ return nil ASSIGN oMenu( oNewMenu ) CLASS TForm - ::oMainMenu = oNewMenu + ::oMainMenu := oNewMenu WinSetParent( oNewMenu:nHandle, ::hWnd, .t. ) WinSetOwner( oNewMenu:nHandle, ::hWnd ) diff --git a/harbour/contrib/hgf/os2pm/tmenu.prg b/harbour/contrib/hgf/os2pm/tmenu.prg index a4b82bc324..295b9915dc 100644 --- a/harbour/contrib/hgf/os2pm/tmenu.prg +++ b/harbour/contrib/hgf/os2pm/tmenu.prg @@ -59,19 +59,21 @@ CLASS TMenu - DATA nHandle // Handle of this SUBMENU (be it top level or drop down) + DATA nHandle // Handle of MIS_ACTIONBAR DATA aItems // Items inside this menu + DATA oParent // Parent/Owner of menu - METHOD New( oForm ) - METHOD Add( oMenuItem ) + METHOD New(oForm) + METHOD Add(oMenuItem) ENDCLASS METHOD New( oForm ) CLASS TMenu - ::aItems = {} - ::nHandle = WinCreateMenu( oForm:hWnd ) + ::aItems := {} + ::oParent := oForm + ::nHandle := WinCreateMenu( oForm:hWnd ) return Self @@ -79,7 +81,7 @@ return Self METHOD Add( oMenuItem ) CLASS TMenu WinAddMenuItem( ::nHandle, oMenuItem:cCaption, MIT_END,; - oMenuItem:nHandle, oMenuItem:nId, oMenuItem:lEnabled ) + nil, oMenuItem:nId, oMenuItem:lEnabled ) AAdd( ::aItems, oMenuItem ) diff --git a/harbour/contrib/hgf/os2pm/tmenuitm.prg b/harbour/contrib/hgf/os2pm/tmenuitm.prg index 9b9f439c90..6e181b7270 100644 --- a/harbour/contrib/hgf/os2pm/tmenuitm.prg +++ b/harbour/contrib/hgf/os2pm/tmenuitm.prg @@ -60,19 +60,19 @@ CLASS TMenuItem - 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 + 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 - 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 + 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 submenu window (if there is any) - CLASSDATA nIdStart // start value for commands value to assign to menu items + 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 + METHOD New( oOwner ) // Creates a new menu item + METHOD Add( oMenuItem ) // Adds a new drop down menu item ENDCLASS @@ -85,15 +85,21 @@ METHOD New( oOwner ) CLASS TMenuItem ::nId = ::nIdStart++ ::lEnabled = .t. ::oParent = oOwner - ::nHandle := WinCreateMenu( ::oParent:nHandle ) - ::aItems := {} return Self METHOD Add( oMenuItem ) CLASS TMenuItem - WinAddMenuItem( ::nHandle, oMenuItem:cCaption, MIT_END,; + DEFAULT ::aItems TO {} + + if ::nHandle == nil + ::nHandle := WinCreateMenu( ::oParent:nHandle ) + WinMakeSubMenuItem(::oParent:nHandle, ::nId, ::nHandle) + + endif + + WinAddMenuItem(::nHandle, oMenuItem:cCaption, MIT_END,; nil, oMenuItem:nId, oMenuItem:lEnabled ) AAdd( ::aItems, oMenuItem ) @@ -102,3 +108,5 @@ return nil + + diff --git a/harbour/source/vm/mainstd.c b/harbour/source/vm/mainstd.c index 181cade158..6ca2b27e2f 100644 --- a/harbour/source/vm/mainstd.c +++ b/harbour/source/vm/mainstd.c @@ -80,3 +80,4 @@ char ** __crt0_glob_function( char * _arg ) return 0; } #endif +