Article ID: 141751 - Last Review: November 21, 2006 - Revision: 5.1 How to add control bars to dialog boxes in MFCThis article was previously published under Q141751 This is the 32-bit version of this sample. SUMMARY In a Microsoft Foundation Classes (MFC) application, you
can attach control bars such as status bars and toolbars to a frame window.
However, for many applications a simple dialog box-based user interface is
sufficient. MFC does not provide built-in support for adding control bars to
dialog boxes. DLGCBR32 is a sample application that demonstrates how to add a status bar and toolbar to a dialog box. In addition, it demonstrates a number of techniques related to using a modeless dialog box as the main window of an MFC application. The following files are available for download from the Microsoft Download Center: Visual C++ 6.0Collapse this image ![]() 119591
(http://support.microsoft.com/kb/119591/EN-US/
)
How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most
current virus-detection software that was available on the date that the file
was posted. The file is stored on security-enhanced servers that help to
prevent any unauthorized changes to the file.
Visual C++ .NETCollapse this image ![]() For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base: 119591
(http://support.microsoft.com/kb/119591/EN-US/
)
How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.
MORE INFORMATION To add a control bar to a dialog box, you must create the
control bar as usual, and then make room for the control bar within the client
area of the dialog box. For the control bar to function properly, the dialog
box must duplicate some of the functionality of frame windows. If you want
ON_UPDATE_COMMAND_UI handlers to work for the control bars, you also need to
derive new control bar classes, and handle the WM_IDLEUPDATECMDUI message. If
your dialog box is not the main window of your application, you will also need
to modify its parent frame window to pass the WM_IDLEUPDATECMDUI message on to
the dialog box's control bars. To make room for a control bar within the client area of the dialog box, follow these steps in your dialog box's OnInitDialog() function:
To allow ON_UPDATE_COMMAND_UI handlers to work for other status bar panes and for toolbar buttons, you must derive new control bar classes and implement a message handler for WM_IDLEUPDATECMDUI. This is necessary because the default control bar implementations of OnUpdateCmdUI() assume the parent window is a frame window. However, it doesn't do anything but pass the parent window pointer on to a function which only requires a CCmdTarget pointer. Therefore, you can temporarily tell OnUpdateCmdUI() that the parent window pointer you are giving it is a CFrameWnd pointer to meet the compiler requirements. Here's an example: APPLIES TO
| Article Translations
|

Back to the top
