Note that there are some explanatory texts on larger screens.

plurals
  1. POHow does MFC's "Update Command UI" system work?
    primarykey
    data
    text
    <p>I'd like to know more about how this system works, specifically when and how the framework actually decides to update a UI element.</p> <p>My application has a 'tools' system where a single tool can be active at a time. I used the "ON_UPDATE_COMMAND_UI" message to 'check' the tool's icon/button in the UI, which affected both the application menu and the toolbars. Anyway, this was all working great until some point in the last couple of days, when the toolbar icons stopped getting highlighted properly.</p> <p>I investigated a little and found that the update command was only being received when the icon was actually clicked. What's strange is this is only affecting the toolbars, not the menu, which is still working fine. Even when the buttons in the menu are updated the toolbar icon stays the same.</p> <p>Obviously I've done something to break it - any ideas?</p> <p><strong>EDIT:</strong> Never mind. I'd overwritten the Application's <code>OnIdle()</code> method and hadn't called the original base class method - that is, <code>CWinApp::OnIdle()</code> - which I guess is where the update gets called most of the time. This code snippet from <a href="https://msdn.microsoft.com/en-us/library/3e077sxt.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/3e077sxt.aspx</a> illustrates:</p> <pre><code>BOOL CMyApp::OnIdle(LONG lCount) { // CWinApp's original method is involved in the update message handling! // Removing this call will break things BOOL bMore = CWinApp::OnIdle(lCount); if (lCount == 0) { TRACE(_T("App idle for short period of time\n")); bMore = TRUE; } // ... do work return bMore; // return TRUE as long as there are any more idle tasks } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload