-
September 9th, 2009, 01:42 AM
#1
[RESOLVED] Can I send OnUpdateX(CCmdUI* pCmdUI) message
It is well documented how to override the OnUpdate notitifcation for menu items but is there any way to send that notification to the main window to get a state of a certain menu item command?
-
September 9th, 2009, 01:56 AM
#2
Re: Can I send OnUpdateX(CCmdUI* pCmdUI) message
You might be approaching the problem from the wrong angle.
The update command handlers [typically] uses document data to determine the appropriate menu item state (disabled, enabled, checked, etc).
Given that, since the document is available anywhere from within the app, can't you call the document method used by the update command handler directly?
-
September 9th, 2009, 02:38 AM
#3
Re: Can I send OnUpdateX(CCmdUI* pCmdUI) message
No unfortunately I can't. All I can do is to send a message to the main window and get the result. I was hoping to use an already built it functionality (if OnUpdateX(CCmdUI* pCmdUI) is implemented via messages at all).
-
September 9th, 2009, 05:16 AM
#4
Re: Can I send OnUpdateX(CCmdUI* pCmdUI) message
Calling the update handlers is an often used method to generically set various UI elements in a generic class/library without tying them to your document implementation specifically so it's not all that strange and actually better than repeating the conditions for enabling throughout your UI, even if all the conditions are nicely packed in the document.
For a popup menu you'd do
Code:
CCmdUI CmdUI;
CmdUI.m_pOther = pCmdWnd; // Window owning the menu
CmdUI.m_pMenu = pMenu; // The CMenu pointer you're trying to update
CmdUI.m_nIndexMax = pMenu->GetMenuItemCount();
for (CmdUI.m_nIndex = 0; CmdUI.m_nIndex<CmdUI.m_nIndexMax; CmdUI.m_nIndex++)
{
CmdUI.m_nID = CmdUI.m_pMenu->GetMenuItemID(CmdUI.m_nIndex);
if (CmdUI.m_nID && CmdUI.m_nID!=(UINT)-1) // Separator = 0, Popup is -1
CmdUI.DoUpdate(pCmdWnd, FALSE);
}
-
September 9th, 2009, 04:07 PM
#5
Re: Can I send OnUpdateX(CCmdUI* pCmdUI) message
Hey, you're the man! Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|