Prev: CListCtrl transparent
Next: CPrintDialogEx problem
From: William on 11 Sep 2007 23:33 Env: WindowsXP, VC++6.00 I am trying to make a MDI application with two dynamic toolbars. I did as follows, BOOL CTest1App::InitInstance() { //using *.ini to save the information LoadStdProfileSettings(); } class CMainFrame : public CMDIFrameWnd { CToolBar m_wndToolBar; CToolBar m_wndToolBar2; } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; } if (!m_wndToolBar2.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar2.LoadToolBar(IDR_MAINFRAME2)) { TRACE0("Failed to create toolbar\n"); return -1; } m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); m_wndToolBar2.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar, AFX_IDW_DOCKBAR_TOP); DockControlBar(&m_wndToolBar2, AFX_IDW_DOCKBAR_TOP); LoadBarState("ToolbarInf"); } void CMainFrame::OnClose() { SaveBarState("ToolbarInf"); CMDIFrameWnd::OnClose(); } When I try to run it, I can change these positions. But when I exit it and run it again, m_wndToolBar2 is always at lept-top position. TIA William
From: David Ching on 12 Sep 2007 00:10 "William" <port(a)mx15.freecom.ne.jp> wrote in message news:%23wT$j2O9HHA.1484(a)TK2MSFTNGP06.phx.gbl... > Env: WindowsXP, VC++6.00 > > I am trying to make a MDI application with two dynamic toolbars. I did as > follows, > > BOOL CTest1App::InitInstance() > { > //using *.ini to save the information > LoadStdProfileSettings(); > } > > class CMainFrame : public CMDIFrameWnd > { > CToolBar m_wndToolBar; > CToolBar m_wndToolBar2; > } > > int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) > { > if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | > CBRS_TOP > | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || > !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) > { > TRACE0("Failed to create toolbar\n"); > return -1; > } > > if (!m_wndToolBar2.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | > CBRS_TOP > | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || > !m_wndToolBar2.LoadToolBar(IDR_MAINFRAME2)) > { > TRACE0("Failed to create toolbar\n"); > return -1; > } > > m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); > m_wndToolBar2.EnableDocking(CBRS_ALIGN_ANY); > > EnableDocking(CBRS_ALIGN_ANY); > > DockControlBar(&m_wndToolBar, AFX_IDW_DOCKBAR_TOP); > DockControlBar(&m_wndToolBar2, AFX_IDW_DOCKBAR_TOP); > > LoadBarState("ToolbarInf"); > } > > void CMainFrame::OnClose() > { > SaveBarState("ToolbarInf"); > > CMDIFrameWnd::OnClose(); > } > > When I try to run it, I can change these positions. But when I exit it and > run it again, m_wndToolBar2 is always at lept-top position. > > TIA > > William > After exiting the app, can you look in the registry and see if the saved position looks like it corresponds with where m_wndToolbar2 was docked at? Also, when I call DockControlBar(), I don't specify the second parameter - AFX_IDW_DOCKBAR_TOP. Just leave it out so it defaults to 0 and see if this makes a difference. -- David
From: William on 12 Sep 2007 00:47 Thanks David. Since I don't use SetRegistryKey() at CTest1App::InitInstance(), the information will be saved at C:\Windows\MyApp.ini. if I use SetRegistryKey(), Of course, I can see the information in the registry. Unfortunately, I really don't understand the meaning written at the ini or registry. Because I guess MSDN fails to document it clearly. I just tried DockControlBar(&m_wndToolBar2) instead of DockControlBar(&m_wndToolBar, AFX_IDW_DOCKBAR_TOP). But the result is the same. William > After exiting the app, can you look in the registry and see if the saved > position looks like it corresponds with where m_wndToolbar2 was docked at? > > Also, when I call DockControlBar(), I don't specify the second parameter - > AFX_IDW_DOCKBAR_TOP. Just leave it out so it defaults to 0 and see if > this makes a difference.
From: Dan Bloomquist on 12 Sep 2007 02:05 William wrote: > Thanks David. > > Since I don't use SetRegistryKey() at CTest1App::InitInstance(), the > information will be saved at C:\Windows\MyApp.ini. if I use > SetRegistryKey(), Of course, I can see the information in the registry. > Unfortunately, I really don't understand the meaning written at the ini > or registry. Because I guess MSDN fails to document it clearly. > > I just tried DockControlBar(&m_wndToolBar2) instead of > DockControlBar(&m_wndToolBar, AFX_IDW_DOCKBAR_TOP). But the result is > the same. > > William > > >> After exiting the app, can you look in the registry and see if the >> saved position looks like it corresponds with where m_wndToolbar2 was >> docked at? >> >> Also, when I call DockControlBar(), I don't specify the second >> parameter - AFX_IDW_DOCKBAR_TOP. Just leave it out so it defaults to >> 0 and see if this makes a difference. > > I've been though the dock hell in the past. First thing I had learned was something about afxres.h where: .... #define AFX_IDW_TOOLBAR 0xE800 // main Toolbar for window #define AFX_IDW_STATUS_BAR 0xE801 // Status bar window #define AFX_IDW_PREVIEW_BAR 0xE802 // PrintPreview Dialog Bar #define AFX_IDW_RESIZE_BAR 0xE803 // OLE in-place resize bar #define AFX_IDW_REBAR 0xE804 // COMCTL32 "rebar" Bar #define AFX_IDW_DIALOGBAR 0xE805 // CDialogBar .... So, I define my dialog bar id's at 0xE805 + 1. And, of course, I can't: (AFX_IDW_DIALOGBAR + 1) doesn't work so have to do them raw. And of course they show as: 59397, 59398... in the resource view in the stead of my ids. Maybe I'm doing something wrong. But, most likely, MFC and VS are incompatible here, just plain broken......... I have 2008 beta install on the laptop now but have not been there to see if it is fixed, or if I still don't get it.........
From: William on 12 Sep 2007 03:27
The problem has been solved by Q232845 at MSDN. William |