Simple menu question
-
I need to update the check on my menu item so created a message handler to my UPDATE_COMMAND_UI event. The code is as follows:
void CSpDlg::OnUpdateShowPeak(CCmdUI *pCmdUI)
{// Update menu
pCmdUI->SetCheck( m_bShowPeakVoltage );}
The menu item does not update, however. I'm I missing something? Thanks.
-
I need to update the check on my menu item so created a message handler to my UPDATE_COMMAND_UI event. The code is as follows:
void CSpDlg::OnUpdateShowPeak(CCmdUI *pCmdUI)
{// Update menu
pCmdUI->SetCheck( m_bShowPeakVoltage );}
The menu item does not update, however. I'm I missing something? Thanks.
If u need it before creating use the flags MF_CHECKED You need to use DrawMenuBar() after you do any modification to the menu . The CheckMenuItem function sets the state of the specified menu item's check-mark attribute to either selected or clear. Good MSDN article http://msdn.microsoft.com/en-us/library/ms647558(VS.85).aspx[^]
Vikas Amin
My First Article on CP" Virtual Serail Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
-
I need to update the check on my menu item so created a message handler to my UPDATE_COMMAND_UI event. The code is as follows:
void CSpDlg::OnUpdateShowPeak(CCmdUI *pCmdUI)
{// Update menu
pCmdUI->SetCheck( m_bShowPeakVoltage );}
The menu item does not update, however. I'm I missing something? Thanks.
I would suggest adding your command to a toolbar to see if that updates or not. I see your command is in a dialog. Is this a formview? If it is a modeless window, the command messages may not be routing there. Try adding the updateui handler to whatever is your
CMainFrame
(look inCMyApp::InitInstance
to see what is being assigned to m_pMainWnd. Have a read / google aboutOnCmdMsg
- it may give you the clues about message routing that help you. Good luck - missing messages are not magic, but they can be a pain to track down. Iain. -
I need to update the check on my menu item so created a message handler to my UPDATE_COMMAND_UI event. The code is as follows:
void CSpDlg::OnUpdateShowPeak(CCmdUI *pCmdUI)
{// Update menu
pCmdUI->SetCheck( m_bShowPeakVoltage );}
The menu item does not update, however. I'm I missing something? Thanks.
For a dialog, you need to handle the undocumented WM_KICKIDLE message to get the command enablers working. See: WM_KICKIDLE for Updating MFC Dialog Controls[^] If you are tracking a popup menu, you may need to set the menu item states before calling TrackPopupMenu(Ex). Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: