Professional UI Solutions
Site Map   /  Register


Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Problem with Messages of Dialog inside a CExt Collapse All
Subject Author Date
Sebastian Baumgärtner Nov 16, 2006 - 10:48 AM


I recently started using Prof-UI to build a GUI which is on top of MFC and has a much nicer design. I started to evaluate the dockable ControlBar of Cristi Posea ( where I came to your product afterwards.
I found your CExtControlBar to be very useful, especially with a hosted dialog inside and the samples look very promising to me.
I would like to create something as the MDI- or MDIDOCVIEW application. In MDIDOCVIEW, the resizable bar has two buttons. How and where do I have to handle or forward the messages of those buttons?? I used Spy++ to see to which Window they are transported and the only Window where they arrive is the CExtResizableDialog, which is the parent of the buttons.
Where can I put code to react on ON_BN_CLICKED messages??? How can I generally react on the messages?? It does work when I open the resource editor and add message handler to the desired classes. Of course, they are not routed there.

Do I have to create a subclass of CExtResizableDialog where I have to override the OnCmdMsg function, in order to route messages to a desired Window or the application itself?
Using the Cristi Posea’s resizable Control Bar, I placed a sublcassed FormView inside the ControlBar and it works that way.

To better understand me, here’s a frameshot of the GUI I would like to build:

It’s no problem for me to send you an demo project.

Thanks, Sebastian

Norman Tellinot Nov 19, 2006 - 3:07 PM

Subclassing OnCmdMsg works for handling of the commands... but what can I do about updating command state?

Technical Support Nov 21, 2006 - 3:25 AM

You can get more info about OnCmdMsg() in MSDN. The nCode parameter is the command notification code and the pExtra parameter depends on the value of nCode. When the nCode parameter is equal to CN_UPDATE_COMMAND_UI, pExtra is a pointer to the CCmdUI object which is used for controlling the command state.

Sebastian Baumgärtner Nov 18, 2006 - 7:35 AM


thank you for your help!!! I found this out having a look at the SKINNABLE example where a subclassed CExtDialog is put into a dynamic control bar. I grabbed that idea and put my desired dialog inside the CExtControlBar. Works perfect this way and it is the same as written in the FAQ.

By the way... By subclassing the CExtDialog one is able to overwrite the virtual OnCmdMsg function to handle or send desired messages elsewhere. Handling in the subclassed CExtDialog class is possible too, of course.

Thanks for the help, Sebastian

Norman Tellinot Nov 17, 2006 - 12:49 AM

Oops, you’re right - I didn’t know what I was talking about.

I thought I had done this, but instead, what I had done was put the ON_COMMAND message handler in my dialog subclass (which you said works), and it in turn has a reference to my CDocument-based class, and it calls a method on the document.

This solution works for both the regular MFC CDialogBar, and prof-uis’s CExtResizableDialog. However, it means there is a tight coupling between your dialog and a document class, so it’s not the best solution.

I haven’t tried it, but maybe you could, in your command handler in your dialog class, rebroadcast the command using something like AfxGetMainWnd()->PostMessage(WM_COMMAND, IDC_BUTTON1), and then your active frame/view/doc would catch it.

Sebastian Baumgärtner Nov 16, 2006 - 11:25 AM


I placed a ON_COMMAND(IDC_BUTTON1, OnBnClickedButton1) inside the MESSAGE_MAP of either MaineFrame MyApp or the View and the correponding handler OnBnClickedButton1 is executed nowhere.

Considere the MDI sample:

I added: ON_COMMAND(IDOK, test) to the MainFrame’s MESSAGE-MAP


void CMainFrame::test(){


// Generated message map functions
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    afx_msg void test();

to the header and source respectively. The message from the button does not arrive and is not handled.


Technical Support Nov 17, 2006 - 11:12 AM

We have just added a FAQ that should help you with this:

How to add a custom button to the caption of my control bar?

Norman Tellinot Nov 16, 2006 - 11:04 AM

You should just need to add a handler for those commands somewhere in your view/doc/frame.