Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

CStatusBar & CToolBar in a CReBar on a modeless dialog and ON_UPDATE_COMMAND_UI

Posted on 2002-04-29
2
949 Views
Last Modified: 2013-11-20
My app is an ATL COM EXE server (out-of-proc)  with MFC support added in.  I have an invisible main window, whose main purpose in life is to provide the app's message pump.

I also have a modeless dialog which is the application's primary window.  On this dialog I have a CReBar, and in the CReBar are 2 bands; a CToolBar and a CStatusBar.

I would like to use MFC's ON_UPDATE_COMMAND_UI mechanism to update both the enabled-state of the buttons in the toolbar and the indicators of the status bar, but I can't get it to work.  My ON_UPDATE_COMMAND_UI handlers for the individual controls (example, the button in the toolbar) are never called in the controlbar.  The update-handlers are fired in the dialog class for the dialog's menubar, but they are not fired in the CReBar or CStatusBar or CToolBar classes.

I am using the technique outlined in 'MFC Answer Book' FAQ # 6.10 and FAQ # 4.8, but it's not working as advertised.

Could anyone shed any light on this for me?  Has anyone else done something like what I am doing?

Thanks for the use of your brain.
0
Comment
Question by:quando
2 Comments
 
LVL 12

Accepted Solution

by:
migel earned 300 total points
ID: 6979689
Hi!
I think that this happens due to CControlBar class design
its implementation checks is CFrameWnd derived class in the parents chain and if none of that found just not start UpdateUI mechanism.
Try derive your own classes for CRebar, CToolBar and CStatusBar and handle:
WM_IDLEUPDATECMDUI (you nee to include "afxpriv.h" to use this message)
for example:
// your dialog class h file
ON_MESSAGE(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)
LRESULT OnIdleUpdateCmdUI(WPARAM wParam, LPARAM)

///cpp file
LRESULT CControlBar::OnIdleUpdateCmdUI(WPARAM wParam, LPARAM)
{
     // handle delay hide/show
     BOOL bVis = GetStyle() & WS_VISIBLE;
     UINT swpFlags = 0;
     if ((m_nStateFlags & delayHide) && bVis)
          swpFlags = SWP_HIDEWINDOW;
     else if ((m_nStateFlags & delayShow) && !bVis)
          swpFlags = SWP_SHOWWINDOW;
     m_nStateFlags &= ~(delayShow|delayHide);
     if (swpFlags != 0)
     {
          SetWindowPos(NULL, 0, 0, 0, 0, swpFlags|
               SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
     }

     // the style must be visible and if it is docked
     // the dockbar style must also be visible
     if ((GetStyle() & WS_VISIBLE) &&
          (m_pDockBar == NULL || (m_pDockBar->GetStyle() & WS_VISIBLE)))
     {
          CFrameWnd* pTarget = (CFrameWnd*)GetOwner();
          if (pTarget == NULL || !pTarget->IsKindOf(RUNTIME_CLASS(CMyDialog))) /// << main changes here!
               pTarget = GetParent(); /// << change too
          if (pTarget != NULL)
               OnUpdateCmdUI(pTarget, (BOOL)wParam);
     }
     return 0L;
}
0
 
LVL 1

Author Comment

by:quando
ID: 7003727
Sorry, I forgot that I had asked this question.  I solved this problem long ago on my own.

Miguel, you were close enough to right.  
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Turn a spreadsheet into a vba executable. 2 92
abstract class with all non abstract mentods 6 79
wordmultiple challenge 12 141
Capture logon name 13 87
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question