PRB: Control Bar Not Visible After Calling Create (111768)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++ for Windows, 16-bit edition 1.0
- Microsoft Visual C++ for Windows, 16-bit edition 1.5
- Microsoft Visual C++ for Windows, 16-bit edition 1.51
- Microsoft Visual C++ for Windows, 16-bit edition 1.52
- Microsoft Visual C++, 32-bit Editions 2.0
- Microsoft Visual C++, 32-bit Editions 2.1
- Microsoft Visual C++, 32-bit Editions 4.0
This article was previously published under Q111768 SYMPTOMS
A control bar is not immediately visible after a call to Create. The
control bar becomes visible only when the parent window is resized (or
minimized\maximized). This behavior is true for all the built-in framework
classes derived from CControlBar:
CDialogBar
CToolBar
CStatusBar
CAUSE
A control bar is initially placed at position (0,0) with size (0,0) so that
the parent frame can control the size and position. The size and position
are recomputed when a call is made to RecalcLayout. If a call is made to
Create, then the control bar will not become visible until RecalcLayout is
called for the parent frame window. The control bar becomes visible when
the main frame window is resized, because CFrameWnd has a WM_SIZE handler
that calls RecalcLayout.
RESOLUTION
Use one of the following to resolve this issue: - If the control bar is ALWAYS going to be attached to the frame window
when it is created, then create the control bar once in the OnCreate
message handler for the frame window. This would apply to the main frame
window of an SDI (CFrameWnd) or MDI (CMDIFrameWnd) application, or to an
MDI Child Window (CMDIChildWnd).
- If the control is to be created dynamically (for example, a toolbar that
pops-up only under certain circumstances), make a call to RecalcLayout
for the parent frame window to cause the control bar to be properly
resized and drawn.
Modification Type: | Major | Last Reviewed: | 12/1/2003 |
---|
Keywords: | kbMFCCtrlBar kbprb kbToolbar KbUIDesign KB111768 |
---|
|