06-24-2013, 03:42 AM
WM_ACTIVATE/WA_INACTIVE is not a good place to show message box. Also goto messages2 can be used only with WM_COMMAND.
To disable popup menu items, use class MenuPopup instead of function ShowMenu:
To disable items when using menu bar:
Function Dialog126
3. In dialog editor select an Edit control, click Events, EN_KILLFOCUS.
,case WM_ACTIVATE
,sel wParam
,,case WA_INACTIVE
,,,;mes("Disabled!")
,,,if(!MessageBox(0 "Disabled!" "QM" MB_TOPMOST)) end ERR_FAILED ;;returns 0, then mes throws error
To disable popup menu items, use class MenuPopup instead of function ShowMenu:
MenuPopup m.AddItems("1 Enabled[]2 Disabled[]3 Disabled[]4 Enabled[]5 Disabled")
m.DisableItems("2-3 5")
out m.Show
Function Dialog126
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
if(!ShowDialog("Dialog126" &Dialog126 0 0 0 0 0 0 0 0 "" "Dialog126")) ret
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;3 Button 0x54032000 0x0 6 8 48 14 "Button"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030507 "*" "" "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3
,int hm=GetMenu(hDlg)
,EnableMenuItem hm 103 MF_ENABLED
,EnableMenuItem hm 104 MF_ENABLED
,EnableMenuItem hm 105 MF_GRAYED
,case IDOK
,case IDCANCEL
ret 1
;BEGIN MENU
;>&Edit
,;&Cut : 103 0 3
,;&Copy : 104 0 3
,;&Paste : 105
,;<
;END MENU
3. In dialog editor select an Edit control, click Events, EN_KILLFOCUS.