Q: ON_UPDATE_COMMAND_UI not working properly 
Author Message
 Q: ON_UPDATE_COMMAND_UI not working properly

Hi.

I have a menu[File, Action, Options]. Clicking the Action-Menu drops down a
list of commands [Open, Execute, Skip]. I've added an update-command handler
function for the ActionExe item.

    ON_COMMAND(ID_BATCH_ACTIONS_EXE, OnActionsExe)
    ON_UPDATE_COMMAND_UI(ID_BATCH_ACTIONS_EXE, OnUpdateActionsExe)

My problem is that the OnUpdateActionsExe() method is not called when I drop
down the Action-menu list! It is however called if I click the execute
command. (Both the OnActionsExe() function and the OnUpdateActionsExe() is
called then).
I seem to be missing the call when I drop down the action list. WHY?????

/ Rob

// In header
    afx_msg void OnActionsExe();
    afx_msg void OnUpdateActionsExe(CCmdUI* pCmdUI);

// In cpp
void CDlgBatchMain::OnActionsExe()
{
    m_ctrlList.Execute();

Quote:
}

void CDlgBatchMain::OnUpdateActionsExe(CCmdUI* pCmdUI)
{
     pCmdUI->Enable(m_ctrlList.EnableMenu(IDS_BATCHCONTEXT_EXE));
Quote:
}



Mon, 03 Jun 2002 03:00:00 GMT  
 Q: ON_UPDATE_COMMAND_UI not working properly

Quote:

>I seem to be missing the call when I drop down the action list. WHY?????

Judging by your class name your menu is in a dialog. That's why. The
dispatcher code for ON_UPDATE_COMMAND_UI is in CFrameWnd, but CDialog
is derived from CWnd, so it doesn't inherit this code.

Handle WM_INITMENUPOPUP and do your own updating there. You can even
nick the code from CFrameWnd to do it.... or so I'm told.

--
Bob Moore [MVP]
http://www.mooremvp.freeserve.co.uk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Due to an unreasonable amount of queries, I no
longer answer unsolicited email questions. Sorry,
no exceptions.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Mon, 03 Jun 2002 03:00:00 GMT  
 Q: ON_UPDATE_COMMAND_UI not working properly
Rob,

Amen to what Bob said. This problem is often a result of adding a menu to a
dialog-based application. If this is what you are trying to do, try an SDI,
formview application instead.

--
Dave Smith
MCSE, MCT, MVP

Quote:


>>I seem to be missing the call when I drop down the action list. WHY?????

>Judging by your class name your menu is in a dialog. That's why. The
>dispatcher code for ON_UPDATE_COMMAND_UI is in CFrameWnd, but CDialog
>is derived from CWnd, so it doesn't inherit this code.

>Handle WM_INITMENUPOPUP and do your own updating there. You can even
>nick the code from CFrameWnd to do it.... or so I'm told.

>--
>Bob Moore [MVP]
>http://www.mooremvp.freeserve.co.uk
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>Due to an unreasonable amount of queries, I no
>longer answer unsolicited email questions. Sorry,
>no exceptions.
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Mon, 03 Jun 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Q: ON_UPDATE_COMMAND_UI not working properly

2. CFile not working properly, can't figure out why (last message not sent properly)

3. ON_UPDATE_COMMAND_UI not working as expected

4. Tab key to tab between controls does not work properly

5. Scroll bars not working properly

6. AtlReportError not working in ATL 7.0 (Injected code doesn't handle ErrorInfo properly)

7. Links not working properly in the Object Browser

8. mouse_event for mouse move is not working properly.

9. gets() and fgets() Not Working Properly - Source Included

10. Tab not working properly in control

11. Auto Complete feature does not work properly in Visual C++ 6.0

12. Auto Completion does not work properly!!!

 

 
Powered by phpBB® Forum Software