Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Disable File Menu Item
#1
I would like to have a file menu in a dialog with a save option.

When the dialog loads I'd like the "Save" to be disabled.

When changes have been made in the dialog, the "Save" would be then become available.

Also, I would like a test function to get whether "Save" is enabled/disabled.

Code:
Copy      Help
;BEGIN MENU
;>&File
,;&Publications : 1001
,;&Advertisers : 1002
,;&Save : 1010 0 0 Cs
,;<
;>&Help
,;&View Help : 1005 0 0 F1
,;-
,;&About : 1006
,;<
;Save : 1010
;END MENU
#2
Found it in the forum:
int hm=GetMenu(hDlg) ;;menu bar
EnableMenuItem hm 1010 MF_GRAYED

When I try to enable menu item:
int hm=GetMenu(hDlg) ;;menu bar
EnableMenuItem hm 1010 MF_ENABLED

It does work, but it doesn't actually show the menu item in black until I mouse over the text.
This is being triggered by a change in QM Grid:
Code:
Copy      Help
,,case GRID.LVN_QG_CHANGE ;;when user changes grid content
,,int hm=GetMenu(hDlg) ;;menu bar
,,EnableMenuItem hm 1010 MF_ENABLED



Had to change my menu a bit: (Would disable "Save" under file, but not the one out in the open)
BEGIN MENU
>&File
&Publications : 1001
&Advertisers : 1002
<
>&Help
&View Help : 1005 0 0 F1
-
&About : 1006
<
Save : 1010 0 0
END MENU


I am having troubles with this: (it shows Ctrl+S in the menu in place of "Save" which is why I had "Save" under File menu)
BEGIN MENU
>&File
&Publications : 1001
&Advertisers : 1002
<
>&Help
&View Help : 1005 0 0 F1
-
&About : 1006
<
Save : 1010 0 0 Cs
END MENU
#3
Problems when two menu items have same id.
Use different id, and disable/enable both.

Quote:Also, I would like a test function to get whether "Save" is enabled/disabled.
Use variables for this. Don't rely on state of menu items or controls.
#4
If using the last menu definition, you can change menu item string.
Code:
Copy      Help
,case WM_INITDIALOG
,MenuSetString GetMenu(hDlg) 1010 "Save"


Forum Jump:


Users browsing this thread: 1 Guest(s)