Menu Enabling
-
I have to cal this function to enable menu.. OnUpdateFileExit(?)--- what i have to pass in place of CCmdUI argument... confused void BrowserManager::OnUpdateFileExit(CCmdUI *pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->Enable ( TRUE ); }
-
I have to cal this function to enable menu.. OnUpdateFileExit(?)--- what i have to pass in place of CCmdUI argument... confused void BrowserManager::OnUpdateFileExit(CCmdUI *pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->Enable ( TRUE ); }
The OnUpdateXXX handlers should be called auto-magically by the framework when the message ON_UPDATE_COMMAND_UI message is sent. you need to add a message for that ... add something like in the message map area of (I don't remember which one) either the application (CWinApp derived class) or the main frame class.:
ON_UPDATE_COMMAND_UI( ID_OF_YOUR_MENU_ITEM, OnUpdateFileExit)
IMO, the Exit menu (quit?) should always be enable.
Watched code never compiles.
-
The OnUpdateXXX handlers should be called auto-magically by the framework when the message ON_UPDATE_COMMAND_UI message is sent. you need to add a message for that ... add something like in the message map area of (I don't remember which one) either the application (CWinApp derived class) or the main frame class.:
ON_UPDATE_COMMAND_UI( ID_OF_YOUR_MENU_ITEM, OnUpdateFileExit)
IMO, the Exit menu (quit?) should always be enable.
Watched code never compiles.
What i want exactly i have a menu item disabled initially.. ? I have a function which check wheteher a Sotware present in System or not and retruns true/false... If it returns true i have to enable the menu item.. If it retuns false do nothing... Can u explain me how to do this... :)
-
What i want exactly i have a menu item disabled initially.. ? I have a function which check wheteher a Sotware present in System or not and retruns true/false... If it returns true i have to enable the menu item.. If it retuns false do nothing... Can u explain me how to do this... :)
The ON_UPDATE_COMMAND_UI is called for each menu item when the menu is displayed; So, when that particular menu Item is displayed, the ON_UPDATE_COMMAND_UI handler is called. In the function that you specified for the handler (usually called OnUpdateXXX where XXX is a descriptive name of the function based on the menu item) you will check to see if the software is present or not and enable disable the menu item accordingly. for example (pseudo-coded):
ON_UPDATE_COMMAND_UI( IDM_YOUR_MENU_ITEM, OnUpdateYourMenuItem )
void YourClass::OnUpdateYourMenuItem( CCmdUI* pCmdUI )
{pCmdUI->Enable( IsSoftwarePresentOnSystem() );
}If the function IsSoftwarePresentOnSystem() takes a long time, then it would be a good thing to call it somewhere else and have a state variable. Have fun. M.
Watched code never compiles.
-
The ON_UPDATE_COMMAND_UI is called for each menu item when the menu is displayed; So, when that particular menu Item is displayed, the ON_UPDATE_COMMAND_UI handler is called. In the function that you specified for the handler (usually called OnUpdateXXX where XXX is a descriptive name of the function based on the menu item) you will check to see if the software is present or not and enable disable the menu item accordingly. for example (pseudo-coded):
ON_UPDATE_COMMAND_UI( IDM_YOUR_MENU_ITEM, OnUpdateYourMenuItem )
void YourClass::OnUpdateYourMenuItem( CCmdUI* pCmdUI )
{pCmdUI->Enable( IsSoftwarePresentOnSystem() );
}If the function IsSoftwarePresentOnSystem() takes a long time, then it would be a good thing to call it somewhere else and have a state variable. Have fun. M.
Watched code never compiles.
yes dude.. I did the same way u explained... but still the menu item remains disabled.. dont know where i went wrong... :)
-
yes dude.. I did the same way u explained... but still the menu item remains disabled.. dont know where i went wrong... :)
Can you debug your code ? -If you put a breakpoint in the OnUpdateXXX method, is it triggered when the menu is displayed (when you open a menu) ? -Does the function(s) that check you condition (if the software is there or not) works ? did you validate that before ? M.
Watched code never compiles.