Date: 02-16-2022
Return to Index
created by gbSnippets
'Sometimes, such as in options, you want to group menu sub-items under
'a title so that a user doesn't have to see all of the options all the time.
'It simplifies the visual look but forces the user to drill down to find all options.
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32api.inc"
%IDM_ConfirmDelete = 600 : %IDM_SavePosition = 601
%IDM_Protections = 602 : %IDM_AutoSaveChanges = 603
%IDC_TextBox = 900
Global hDlg As DWord, hMenu As DWord, hMenuOptions As DWord, hMenuProtections as DWord
Function PBMain()
Dialog New Pixels, 0, "MRU Demo",300,300,300,200, %WS_OverlappedWindow To hDlg
Control Add TextBox, hDlg, %IDC_TextBox, " Selected menu description appears here", 30,30,240,125, %WS_Border
AddMenu
Dialog Show Modal hDlg Call DlgProc()
End Function
CallBack Function DlgProc() As Long
Local temp$, iReturn&
Select Case CB.Msg
Case %WM_Command
Select Case CB.Ctl
Case %IDM_ConfirmDelete
Menu Get State hMenuOptions, ByCmd %IDM_ConfirmDelete To iReturn 'get the state
Menu Set State hMenuOptions, ByCmd %IDM_ConfirmDelete, ABS(IsFalse iReturn)*8 'flip the state
Control Set Text hDlg, %IDC_TextBox, " Confirm Delete"
Case %IDM_SavePosition
Menu Get State hMenuOptions, ByCmd %IDM_SavePosition To iReturn 'get the state
Menu Set State hMenuOptions, ByCmd %IDM_SavePosition, ABS(IsFalse iReturn)*8 'flip the state
Control Set Text hDlg, %IDC_TextBox, " Save Position"
Case %IDM_AutoSaveChanges
Menu Get State hMenuOptions, ByCmd %IDM_AutoSaveChanges To iReturn 'get the state
Menu Set State hMenuOptions, ByCmd %IDM_AutoSaveChanges, ABS(IsFalse iReturn)*8 'flip the state
Control Set Text hDlg, %IDC_TextBox, " AutoSave Changes"
End Select
End Select
End Function
Sub AddMenu()
Menu New Bar To hMenu
Menu New Popup To hMenuOptions
'Create Options + Children -------------------------
Menu Add Popup, hMenu, "&Options", hMenuOptions, %MF_Enabled
Menu New Popup To hMenuProtections
Menu Add Popup, hMenuOptions, "&Protections", hMenuProtections, %MF_Enabled
Menu Add String, hMenuProtections, "&Confirm Delete", %IDM_ConfirmDelete, %MF_Enabled
Menu Add String, hMenuProtections, "&Save Position", %IDM_SavePosition, %MF_Enabled
Menu Add String, hMenuOptions, "&AutoSaveChanges", %IDM_AutoSaveChanges, %MF_Enabled
Menu Attach hMenu, hDlg
End Sub
'gbs_00202
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm