--- /dev/null
+////////////////////////////////////////////////////\r
+// Mainfrm.cpp\r
+\r
+#include "stdafx.h"\r
+#include "TabDemoApp.h"\r
+#include "mainfrm.h"\r
+#include "resource.h"\r
+\r
+\r
+// Definitions for the CMainFrame class\r
+CMainFrame::CMainFrame()\r
+{\r
+ //Set the tab control as the fram's view window\r
+ SetView(m_View);\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++\\Container Demo"));\r
+}\r
+\r
+CMainFrame::~CMainFrame()\r
+{\r
+ // Destructor for CMainFrame.\r
+}\r
+\r
+BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)\r
+{\r
+ // OnCommand responds to menu and and toolbar input\r
+\r
+ UNREFERENCED_PARAMETER(lParam);\r
+\r
+ switch(LOWORD(wParam))\r
+ {\r
+ case IDM_FILE_NEW:\r
+ OnFileNew();\r
+ return TRUE;\r
+ case IDM_FILE_CLOSE:\r
+ OnFileClose();\r
+ return TRUE;\r
+ case IDM_FILE_EXIT:\r
+ // End the application\r
+ ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);\r
+ return TRUE;\r
+ case IDM_NEW_FILES:\r
+ m_View.AddTabPage(new CViewFiles, _T("Files"), IDI_FILEVIEW);\r
+ return TRUE;\r
+ case IDM_NEW_CLASSES:\r
+ m_View.AddTabPage(new CViewClasses, _T("Classes"), IDI_CLASSVIEW);\r
+ return TRUE;\r
+ case IDM_TAB_TOP:\r
+ OnTabsAtTop();\r
+ return TRUE;\r
+ case IDM_TAB_BUTTONS:\r
+ OnShowButtons();\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::OnFileClose()\r
+{\r
+ int iTab = m_View.GetCurSel();\r
+\r
+ if (iTab >= 0)\r
+ m_View.RemoveTabPage(iTab);\r
+}\r
+\r
+void CMainFrame::OnFileNew()\r
+{\r
+ // Creates the popup menu when the "New" toolbar button is pressed\r
+\r
+ // Position the popup menu\r
+ CToolBar& TB = GetToolBar();\r
+ RECT rc = TB.GetItemRect(TB.CommandToIndex(IDM_FILE_NEW));\r
+ ::MapWindowPoints(GetToolBar(), NULL, (LPPOINT)&rc, 2);\r
+\r
+ TPMPARAMS tpm;\r
+ tpm.cbSize = sizeof(TPMPARAMS);\r
+ tpm.rcExclude = rc;\r
+\r
+ // Load the popup menu\r
+ CMenu TopMenu(IDM_NEWMENU);\r
+ CMenu* pPopupMenu = TopMenu.GetSubMenu(0);\r
+\r
+ // Start the popup menu\r
+ pPopupMenu->TrackPopupMenuEx(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL, rc.left, rc.bottom, this, &tpm);\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
+ // m_bUseCustomDraw = FALSE; // Don't use custom draw for menu items\r
+\r
+ // call the base class function\r
+ CFrame::OnCreate();\r
+ m_View.SetFixedWidth(TRUE);\r
+ m_View.SetOwnerDraw(TRUE);\r
+}\r
+\r
+void CMainFrame::OnInitialUpdate()\r
+{ \r
+ // Add some tabs to the tab control\r
+ m_View.AddTabPage(new CViewClasses, _T("Classes"), IDI_CLASSVIEW);\r
+ m_View.AddTabPage(new CViewFiles, _T("Files"), IDI_FILEVIEW);\r
+ m_View.AddTabPage(new CViewClasses, _T("Classes"), IDI_CLASSVIEW);\r
+ m_View.AddTabPage(new CViewFiles, _T("Files"), IDI_FILEVIEW);\r
+ m_View.SelectPage(0);\r
+\r
+ // PreCreate initially set the window as invisible, so show it now.\r
+ ShowWindow();\r
+}\r
+\r
+void CMainFrame::OnShowButtons()\r
+{\r
+ BOOL bShow = m_View.GetShowButtons();\r
+ m_View.SetShowButtons(!bShow);\r
+ UINT uCheck = bShow? MF_UNCHECKED : MF_CHECKED;\r
+ ::CheckMenuItem(GetFrameMenu(), IDM_TAB_BUTTONS, uCheck);\r
+ m_View.RedrawWindow();\r
+}\r
+\r
+void CMainFrame::OnTabsAtTop()\r
+{\r
+ BOOL bTop = m_View.GetTabsAtTop();\r
+ m_View.SetTabsAtTop(!bTop);\r
+ \r
+ UINT uCheck = (bTop)? MF_UNCHECKED : MF_CHECKED;\r
+ ::CheckMenuItem(GetFrameMenu(), IDM_TAB_TOP, uCheck);\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
+void CMainFrame::SetupToolBar()\r
+{\r
+ // Set the Resource IDs for the toolbar buttons\r
+ AddToolBarButton( IDM_FILE_NEW );\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
+ // Set the Checkmarks in the menu\r
+ ::CheckMenuItem(GetFrameMenu(), IDM_TAB_BUTTONS, MF_UNCHECKED);\r
+\r
+ // Add some extra icons for menu items\r
+ AddMenuIcon(IDM_NEW_FILES, ::LoadIcon(GetApp()->GetInstanceHandle(), MAKEINTRESOURCE(IDI_FILEVIEW)));\r
+ AddMenuIcon(IDM_NEW_CLASSES, ::LoadIcon(GetApp()->GetInstanceHandle(), MAKEINTRESOURCE(IDI_CLASSVIEW)));\r
+}\r
+\r
+LRESULT CMainFrame::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
+{\r
+// switch (uMsg)\r
+// {\r
+// Add case statements for each messages to be handled here\r
+// }\r
+\r
+ // pass unhandled messages on for default processing\r
+ return WndProcDefault(uMsg, wParam, lParam);\r
+}\r
+\r