The following code is working Ok in Win98 and generating
Menustrings of all main menu and sub-menu items.
Whereas the same code is not working in WinXP and generating
Menustrings only for main menu items.
When bitmaps are used alongwith text in sub-menu items, no
Menustrings (in text) are generated either in Win98 or in WinXp.
This is very essential for me to develop a mechanism to allot
menuitem-wise rights to different users.
I am using these generated menu strings in a tree as shown below and
allowing the superuser to allot rights to his sub-ordinate users by clicking
on the tree items.
Please help.
Regards to you
- Ramesh Babu P
- Code: Select all Expand view RUN
#include "FiveWin.ch"
******
#define MF_ENABLED 0
#define MF_GRAYED 1
#define MF_DISABLED 2
#define MF_BITMAP 4
#define MF_CHECKED 8
#define MF_POPUP 16 // 0x0010
#define MF_BREAK 64
#define MF_BYPOSITION 1024 // 0x0400
#define MF_SEPARATOR 2048 // 0x0800
#define MF_HELP 16384 // 0x4000
#define MF_HILITE 128 // 0x0080
#define MF_UNHILITE 0
#define MF_OWNERDRAW 256 // 0x0100
******
STATIC oWnd
FUNCTION main()
LOCAL oIco, oBar, oBmp
DEFINE WINDOW oWnd FROM 1, 1 TO 22, 75 ;
TITLE "Testing to Get Menu Items" ;
MENU BuildMenu() ;
ICON oIco
ACTIVATE WINDOW oWnd ;
VALID MsgYesNo( "Do you want to quit ?" )
RETURN nil
//----------------------------------------------------------------------------//
FUNCTION BuildMenu()
LOCAL oMenu
LOCAL n
MENU oMenu
MENUITEM "Information"
MENU
MENUITEM "&About..." ;
ACTION MsgInfo( FWDESCRIPTION )
//FILENAME "..\bitmaps\16x16\info.bmp"
SEPARATOR
MENUITEM "&End..." ;
ACTION oWnd:End() //FILENAME "..\bitmaps\16x16\exit.bmp"
ENDMENU
MENUITEM "&Clients"
MENU
MENUITEM "&New..." ;
ACTION ( MsgStop( "New Clients" ),;
oWnd:Say( 5, 5, "New Clients...", "GR+/G" ) )
//FILENAME "..\bitmaps\16x16\faces.bmp"
MENUITEM "&Modify..." ACTION MsgInfo( "Modif. Clients" )
//FILENAME "..\bitmaps\edit.bmp"
MENUITEM "&Delete..." ACTION MsgAlert( "Del Clients" )
//FILENAME "..\bitmaps\16x16\delete.bmp"
SEPARATOR
MENUITEM "&Browse..." ACTION MsgInfo( "Browse Clients" )
//FILENAME "..\bitmaps\16x16\browse.bmp"
ENDMENU
MENUITEM "&Utilities"
MENU
MENUITEM "&Calculator..." ACTION WinExec( "Calc" )
//FILENAME "..\bitmaps\16x16\calc.bmp"
MENUITEM "&Internet..." ;
ACTION WinExec( "start iexplore www.fivetech.com", 0 )
//FILENAME "..\bitmaps\16x16\explorer.bmp"
ENDMENU
ENDMENU
ResBuild( oMenu )
RETURN oMenu
//----------------------------------------------------------------------------//
FUNCTION ResBuild( oMenu )
LOCAL n
LOCAL hMenu := oMenu:hMenu
LOCAL hSubMenu
LOCAL oSubMenu, oMenuItem
FOR n = 1 to GetMItemCount( hMenu )
oMenuItem = TMenuItem():New()
oMenuItem:nId = GetMItemID( hMenu, n - 1 )
oMenuItem:cPrompt = GetMenuString( hMenu, n - 1, MF_BYPOSITION )
oMenuItem:cMsg = ""
oMenuItem:lChecked = lAnd( GetMenuState( hMenu, n - 1, MF_BYPOSITION ), MF_CHECKED )
oMenuItem:lActive = ! lAnd( GetMenuState( hMenu, n - 1,;
MF_BYPOSITION ), nOr( MF_DISABLED, MF_GRAYED ) )
oMenuItem:oMenu = oMenu
oMenuItem:hBitmap = 0
oMenuItem:lHelp = .F.
oMenuItem:lBreak = lAnd( GetMenuState( hMenu, n - 1, MF_BYPOSITION ), MF_BREAK )
AAdd( oMenu:aItems, oMenuItem )
?oMenu:aItems[n]:cPrompt
IF ( hSubMenu := GetSubMenu( hMenu, n - 1 ) ) != 0
oSubMenu = TMenu():New()
oSubMenu:hMenu = hSubMenu
oSubMenu:lSysMenu = .F.
oSubMenu:aItems = {}
oMenuItem:bAction = oSubMenu
ResBuild( oSubMenu )
ENDIF
NEXT
RETURN nil
**********