Disable and grey out menu item
-
In my Dialog Based MFC application i have a menu, one of the items should be disabled and grey upon startup (Maybe i can use the "Grayed" checkbox on the settings for the item?), then a few moments later, usable. Ive searched around alot, yet not find exactly what i want or something 100% working. So far i have created the UPDATE_COMMAND_UI function for the menu item, and put pCmdUI->Enable(false); into it. So now when i click it nothing happens. (its not grey though) So how do i grey it out? thanks!
//Johannes
-
In my Dialog Based MFC application i have a menu, one of the items should be disabled and grey upon startup (Maybe i can use the "Grayed" checkbox on the settings for the item?), then a few moments later, usable. Ive searched around alot, yet not find exactly what i want or something 100% working. So far i have created the UPDATE_COMMAND_UI function for the menu item, and put pCmdUI->Enable(false); into it. So now when i click it nothing happens. (its not grey though) So how do i grey it out? thanks!
//Johannes
1. Make the controls disabled in the dialog template 2. In
OnInitDialog()
, set a timer 3. InOnTimer()
, enable the controls.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Hungarian notation FTW
-
In my Dialog Based MFC application i have a menu, one of the items should be disabled and grey upon startup (Maybe i can use the "Grayed" checkbox on the settings for the item?), then a few moments later, usable. Ive searched around alot, yet not find exactly what i want or something 100% working. So far i have created the UPDATE_COMMAND_UI function for the menu item, and put pCmdUI->Enable(false); into it. So now when i click it nothing happens. (its not grey though) So how do i grey it out? thanks!
//Johannes
Some of the command routing for like menus is not hooked up from CDialog. You can hook it up yourself somehow... I forget... search on MSDN (Using Google if I were you) to find some really really old articles or technical notes about this that show you how to solve the problem.
-
In my Dialog Based MFC application i have a menu, one of the items should be disabled and grey upon startup (Maybe i can use the "Grayed" checkbox on the settings for the item?), then a few moments later, usable. Ive searched around alot, yet not find exactly what i want or something 100% working. So far i have created the UPDATE_COMMAND_UI function for the menu item, and put pCmdUI->Enable(false); into it. So now when i click it nothing happens. (its not grey though) So how do i grey it out? thanks!
//Johannes
There's also CWnd::UpdateDialogControls() which allows the use of ON_UPDATE_COMMAND_UI in dialogs. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
In my Dialog Based MFC application i have a menu, one of the items should be disabled and grey upon startup (Maybe i can use the "Grayed" checkbox on the settings for the item?), then a few moments later, usable. Ive searched around alot, yet not find exactly what i want or something 100% working. So far i have created the UPDATE_COMMAND_UI function for the menu item, and put pCmdUI->Enable(false); into it. So now when i click it nothing happens. (its not grey though) So how do i grey it out? thanks!
//Johannes
Ive looked at UpdateDialogControls() and it seems to be connected with UPDATE_COMMAND_UI. Ive searched around alot, on iGoogle, MSDN and codeproject yet not found something simple and working.. Another thing i dont understand is that UPDATE_COMMAND_UI seems to be executed when the menu item is clicked? but it cant really be clicked if it is disabled... Why cant it be as easy as to enable/disable the other dialog controls.... Thanks for the help :)
//Johannes