Date: 02-16-2022
Return to Index
created by gbSnippets
'With a menu, such as File, where the F is underlined, users are familiar
'with pressing Alt-F to activate the dropdown menu. This requires two
'actions. The F must be preceded by an ampersand (&) and at last one
'control must be present on the dialog.
At least one Control
'Primary Code:
'1. Define the accelerator key using the & symbol
Menu Add Popup, hMenu, "&File", hMenuOptions, %MF_Enabled
'2. Add one control to the dialog
Control Add Button hDlg, 500, "Push", 0,0,0,0
'Compilable Example: (Jose Includes)
'Press Alt+F works in this example, but comment out the Control Add Button
'and it will no longer work. Or remove the & in front of the F and it will
'no longer work.
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32api.inc"
Global hDlg As Dword, hMenu As Dword, hMenuOptions As Dword
Function PBMain()
Dialog New Pixels, 0, "MRU Demo",300,300,300,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 500, "Push", 50,10,50,20
CreateAppMenu
Dialog Show Modal hDlg Call DlgProc()
End Function
Sub CreateAppMenu
Menu New Bar To hMenu
Menu Attach hMenu, hDlg
Menu New Popup To hMenuOptions
Menu Add Popup, hMenu, "&File", hMenuOptions, %MF_Enabled
Menu Add String, hMenuOptions, "&Open", 500, %MF_Enabled
Menu Add String, hMenuOptions, "&Save", 501, %MF_Enabled
End Sub
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = 500 Then MsgBox "Open"
If CB.Msg = %WM_Command AND CB.Ctl = 500 Then MsgBox "Save"
End Function
'gbs_00296
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm