int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; toolbarIconSize.cx = toolbarIconSize.cy = TOOLBAR_MAIN_ICON_SIZE; if ( !m_wndMyFloatingToolbar.Create(this,m_wndMyFloatingToolbar.GetBarStyle() |WS_EX_PALETTEWINDOW | WS_EX_TOPMOST |CBRS_FLOATING | WS_VISIBLE) || !m_wndMyFloatingToolbar.LoadToolBar(IDR_GENERAL_TOOLBAR, toolbarIconSize)) { TRACE0("Failed to create My Floating Toolbar\n"); return -1; // fail to create } m_wndMyFloatingToolbar.EnableDocking(0); EnableDocking(0); if (!CreateCtrlBar()) { TRACE0("Failed to create ctrl toolbar\n"); return -1; // fail to create } // ... //... return 0; } void CMainFrame::OnViewToolBar() { // ... //... CPoint Pos = MyFloatingToolbarGetLastPosition(); \\Get last pos FloatControlBar( &m_wndMyFloatingToolbar, Pos, CBRS_ALIGN_LEFT ); MyFloatingToolbarSetIsVisible(); FloatControlBar( &m_wndMyFloatingToolbar, Pos, CBRS_ALIGN_LEFT ); } void CMainFrame::MyFloatingToolbarSetIsVisible() { WINDOWPLACEMENT wp; m_wndMyFloatingToolbar.GetParent()->GetParent()->GetWindowPlacement(&wp); wp.showCmd = SW_SHOW; m_wndMyFloatingToolbar.GetParent()->GetParent()->SetWindowPlacement(&wp); m_wndMyFloatingToolbar.GetParent()->GetWindowPlacement(&wp); wp.showCmd = SW_SHOW; m_wndMyFloatingToolbar.GetParent()->SetWindowPlacement(&wp); m_wndMyFloatingToolbar.GetWindowPlacement(&wp); wp.showCmd = SW_SHOW; m_wndMyFloatingToolbar.SetWindowPlacement(&wp); } void CWJToolBar::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) { CToolBar::OnWindowPosChanging(lpwndpos); if ( GetBarStyle() & CBRS_FLOATING ) { if((lpwndpos->flags & SWP_HIDEWINDOW) && ((this->GetParentFrame())->m_hWnd !=(this->GetTopLevelFrame())->m_hWnd)) { CMainFrame* mf = (CMainFrame*)(AfxGetApp()->GetMainWnd()); mf->MyFloatingToolbarSavePosition(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)