CWinAppEx CleanState - Reset Layout

I migrated the MFC MDI application to use the new MFC feature package. I have many toolbars and docking panels. As far as I understand, the location and size of each of them is stored in the registry when the application is closed and loaded when the main frame is loaded.

I want to add a function to my application in reset the layout of toolbars / panels to the original layout.

I added a menu item whose command is processed in my CWinAppEx derived class as follows:

 CleanState(); LoadState((CMDIFrameWndEx*)m_pMainWnd); 

But it does not work properly.

However, if I put a call to the CleanState() function before calling LoadMainFrame() , the application will load with the default layout (the one I want).

Is there a way to actually reset the location of my application AFTER downloading it?

Thank you very much.

+4
source share
1 answer

I have no easy answer for you. I had 3 windows for docking using the MFC feature pack in Visual Studio 2017. I called CleanSlate and then installed the docking panels to make sure they were visible. I experimented with the window size of the main frame and the docking windows so that it looks right.

 void CMainFrame::OnButtonWindowResetLayout() { theApp.CleanSlate(); CRect rcInputsOutputs(0, 0, 400, 50); m_wndPaneInputsOutputs.DockToFrameWindow(CBRS_ALIGN_RIGHT, rcInputsOutputs, DT_DOCK_LAST, NULL, -1, FALSE); m_wndPaneInputsOutputs.ShowPane(TRUE); CRect rcDeviceStatus(0, 0, 600, 180); m_wndPaneDeviceStatus.DockToFrameWindow(CBRS_ALIGN_BOTTOM, rcDeviceStatus, DT_DOCK_LAST, NULL, -1, TRUE); m_wndPaneDeviceStatus.ShowPane(TRUE); CRect rcOutput(0, 0, 600, 70); m_wndOutput.DockToFrameWindow(CBRS_ALIGN_BOTTOM, rcOutput, DT_DOCK_LAST, NULL, -1, TRUE); m_wndOutput.ShowPane(TRUE); AdjustDockingLayout(); SetWindowPos(&CWnd::wndTop, 0, 0, 900, 680, SWP_NOMOVE | SWP_NOACTIVATE | SWP_SHOWWINDOW); } 

Each panel class has a function:

 void CPaneDialogEx::ShowPane(BOOL showPane) { if (showPane != IsVisible()) { CMainFrame* pMainFrame = DYNAMIC_DOWNCAST(CMainFrame, GetTopLevelFrame()); if (pMainFrame != NULL) { pMainFrame->SetFocus(); pMainFrame->ShowPane(this, showPane, FALSE, FALSE); pMainFrame->RecalcLayout(); } } } 
0
source

Source: https://habr.com/ru/post/1398842/


All Articles