--- /dev/null
+////////////////////////////////////////////////////\r
+// Mainfrm.cpp\r
+\r
+\r
+#include "stdafx.h"\r
+#include "mainfrm.h"\r
+#include "resource.h"\r
+\r
+\r
+// Definitions for the CMainFrame class\r
+CMainFrame::CMainFrame()\r
+{\r
+ // Constructor for CMainFrame. Its called after CFrame's constructor\r
+\r
+ //Set m_DockView as the view window of the frame\r
+ SetView(m_DockView);\r
+\r
+ // Set the registry key name, and load the initial window position\r
+ // Use a registry key name like "CompanyName\\Application"\r
+ LoadRegistrySettings(_T("Win32++\\Dock"));\r
+}\r
+\r
+CMainFrame::~CMainFrame()\r
+{\r
+ // Destructor for CMainFrame.\r
+}\r
+\r
+BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)\r
+{\r
+ UNREFERENCED_PARAMETER(lParam);\r
+\r
+ // OnCommand responds to menu and and toolbar input\r
+\r
+ switch(LOWORD(wParam))\r
+ {\r
+ case IDM_FILE_EXIT:\r
+ // End the application\r
+ ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);\r
+ return TRUE;\r
+ case IDM_DOCK_DEFAULT:\r
+ SetRedraw(FALSE); // Suppress drawing to the frame window\r
+ m_DockView.CloseAllDockers();\r
+ LoadDefaultDockers();\r
+ SetRedraw(TRUE); // Re-enable drawing to the frame window\r
+ RedrawWindow(0, 0, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW|RDW_ALLCHILDREN);\r
+ return TRUE;\r
+ case IDM_DOCK_CLOSEALL:\r
+ m_DockView.CloseAllDockers();\r
+ return TRUE;\r
+ case IDW_VIEW_STATUSBAR:\r
+ OnViewStatusBar();\r
+ return TRUE;\r
+ case IDW_VIEW_TOOLBAR:\r
+ OnViewToolBar();\r
+ return TRUE;\r
+ case IDM_HELP_ABOUT:\r
+ // Display the help dialog\r
+ OnHelp();\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+void CMainFrame::OnCreate()\r
+{\r
+ // OnCreate controls the way the frame is created.\r
+ // Overriding CFrame::Oncreate is optional.\r
+ // The default for the following variables is TRUE\r
+\r
+ // m_bShowIndicatorStatus = FALSE; // Don't show statusbar indicators\r
+ // m_bShowMenuStatus = FALSE; // Don't show toolbar or menu status\r
+ // m_bUseReBar = FALSE; // Don't use rebars\r
+ // m_bUseThemes = FALSE; // Don't use themes\r
+ // m_bUseToolBar = FALSE; // Don't use a toolbar\r
+\r
+ // call the base class function\r
+ CFrame::OnCreate();\r
+}\r
+\r
+void CMainFrame::OnInitialUpdate()\r
+{\r
+ m_DockView.SetDockStyle(DS_CLIENTEDGE);\r
+\r
+ // Load dock settings\r
+ if (!m_DockView.LoadRegistrySettings(GetRegistryKeyName()))\r
+ LoadDefaultDockers();\r
+\r
+ // PreCreate initially set the window as invisible, so show it now.\r
+ ShowWindow();\r
+}\r
+\r
+void CMainFrame::LoadDefaultDockers()\r
+{\r
+ // Note: The DockIDs are used for saving/restoring the dockers state in the registry\r
+\r
+ DWORD dwStyle = DS_CLIENTEDGE; // The style added to each docker\r
+\r
+ CDocker* pDockLeft = m_DockView.AddDockedChild(new CDockClasses, DS_DOCKED_LEFT | dwStyle, 200, ID_DOCK_CLASSES1);\r
+ CDocker* pDockRight = m_DockView.AddDockedChild(new CDockClasses, DS_DOCKED_RIGHT | dwStyle, 200, ID_DOCK_CLASSES2);\r
+ CDocker* pDockTop = m_DockView.AddDockedChild(new CDockText, DS_DOCKED_TOP | dwStyle, 100, ID_DOCK_TEXT1);\r
+ CDocker* pDockBottom = m_DockView.AddDockedChild(new CDockText, DS_DOCKED_BOTTOM | dwStyle, 100, ID_DOCK_TEXT2);\r
+\r
+ pDockLeft->AddDockedChild(new CDockFiles, DS_DOCKED_BOTTOM | dwStyle, 150, ID_DOCK_FILES1);\r
+ pDockRight->AddDockedChild(new CDockFiles, DS_DOCKED_BOTTOM | dwStyle, 150, ID_DOCK_FILES2);\r
+ pDockTop->AddDockedChild(new CDockSimple, DS_DOCKED_RIGHT | dwStyle, 100, ID_DOCK_SIMPLE1);\r
+ pDockBottom->AddDockedChild(new CDockSimple, DS_DOCKED_RIGHT | dwStyle, 100, ID_DOCK_SIMPLE2);\r
+}\r
+\r
+void CMainFrame::PreCreate(CREATESTRUCT &cs)\r
+{\r
+ // Call the base class function first\r
+ CFrame::PreCreate(cs);\r
+ \r
+ // Hide the window initially by removing the WS_VISIBLE style\r
+ cs.style &= ~WS_VISIBLE;\r
+}\r
+\r
+BOOL CMainFrame::SaveRegistrySettings()\r
+{\r
+ if (CFrame::SaveRegistrySettings())\r
+ return m_DockView.SaveRegistrySettings(GetRegistryKeyName());\r
+ else\r
+ return FALSE;\r
+}\r
+\r
+void CMainFrame::SetupToolBar()\r
+{\r
+ // Set the Resource IDs for the toolbar buttons\r
+ AddToolBarButton( IDM_FILE_NEW, FALSE );\r
+ AddToolBarButton( IDM_FILE_OPEN, FALSE );\r
+ AddToolBarButton( IDM_FILE_SAVE, FALSE );\r
+ \r
+ AddToolBarButton( 0 ); // Separator\r
+ AddToolBarButton( IDM_EDIT_CUT, FALSE );\r
+ AddToolBarButton( IDM_EDIT_COPY, FALSE );\r
+ AddToolBarButton( IDM_EDIT_PASTE, FALSE );\r
+ \r
+ AddToolBarButton( 0 ); // Separator\r
+ AddToolBarButton( IDM_FILE_PRINT, FALSE );\r
+ \r
+ AddToolBarButton( 0 ); // Separator\r
+ AddToolBarButton( IDM_HELP_ABOUT );\r
+}\r