PRB: Control Bar Not Visible After Calling CreateLast reviewed: May 28, 1997Article ID: Q111768 |
The information in this article applies to:
SYMPTOMSA 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 CAUSEA 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.
RESOLUTIONUse one of the following to resolve this issue:
MORE INFORMATIONThere are two code segments below that show how to create a CDialogBar attached to a CMDIChildWnd. The first sample creates a CDialogBar as soon as the child window is created (that is, the child window always has the dialog bar). The second sample shows a function that will properly create and display a dialog bar at any time.
Sample Code
/* Compile options needed: None Sample 1 - Override OnCreate. Note that the dialog template is called IDD_CHILDBAR and that CMyMDIChild has a member variable declaration: CDialogBar m_dlgbar; */ int CMyMDIChild::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1) return -1; m_dlgbar.Create(this,IDD_CHILDBAR,CBRS_TOP,115); return 0; } /* Sample 2 - Creating a dialog bar at any time. Note that the dialog template is called IDD_CHILDBAR and that CMyMDIChildWnd has a member variable declaration: CDialogBar *m_pdlgbar; */ void CMyMDIChild::CreateDialogBar() { m_pDlgBar = new CDialogBar(); m_pDlgBar->Create(this,IDD_CHILDBAR,CBRS_TOP,115); RecalcLayout(); }Because you are allocating a CDialogBar object, you need to call delete m_pDlgBar when you close the application or there will be a memory leak.
|
Additional query words: WM_SIZE CRect tool bar status tool-bar status-bar
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |