1 ////////////////////////////////////////////////////
\r
5 #include "TabDemoApp.h"
\r
7 #include "resource.h"
\r
10 // Definitions for the CMainFrame class
\r
11 CMainFrame::CMainFrame()
\r
13 //Set the tab control as the fram's view window
\r
16 // Set the registry key name, and load the initial window position
\r
17 // Use a registry key name like "CompanyName\\Application"
\r
18 LoadRegistrySettings(_T("Win32++\\Container Demo"));
\r
21 CMainFrame::~CMainFrame()
\r
23 // Destructor for CMainFrame.
\r
26 BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)
\r
28 // OnCommand responds to menu and and toolbar input
\r
30 UNREFERENCED_PARAMETER(lParam);
\r
32 switch(LOWORD(wParam))
\r
37 case IDM_FILE_CLOSE:
\r
41 // End the application
\r
42 ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
\r
45 m_View.AddTabPage(new CViewFiles, _T("Files"), IDI_FILEVIEW);
\r
47 case IDM_NEW_CLASSES:
\r
48 m_View.AddTabPage(new CViewClasses, _T("Classes"), IDI_CLASSVIEW);
\r
53 case IDM_TAB_BUTTONS:
\r
56 case IDW_VIEW_STATUSBAR:
\r
59 case IDW_VIEW_TOOLBAR:
\r
62 case IDM_HELP_ABOUT:
\r
63 // Display the help dialog
\r
71 void CMainFrame::OnFileClose()
\r
73 int iTab = m_View.GetCurSel();
\r
76 m_View.RemoveTabPage(iTab);
\r
79 void CMainFrame::OnFileNew()
\r
81 // Creates the popup menu when the "New" toolbar button is pressed
\r
83 // Position the popup menu
\r
84 CToolBar& TB = GetToolBar();
\r
85 RECT rc = TB.GetItemRect(TB.CommandToIndex(IDM_FILE_NEW));
\r
86 ::MapWindowPoints(GetToolBar(), NULL, (LPPOINT)&rc, 2);
\r
89 tpm.cbSize = sizeof(TPMPARAMS);
\r
92 // Load the popup menu
\r
93 CMenu TopMenu(IDM_NEWMENU);
\r
94 CMenu* pPopupMenu = TopMenu.GetSubMenu(0);
\r
96 // Start the popup menu
\r
97 pPopupMenu->TrackPopupMenuEx(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL, rc.left, rc.bottom, this, &tpm);
\r
100 void CMainFrame::OnCreate()
\r
102 // OnCreate controls the way the frame is created.
\r
103 // Overriding CFrame::Oncreate is optional.
\r
104 // The default for the following variables is TRUE
\r
106 // m_bShowIndicatorStatus = FALSE; // Don't show statusbar indicators
\r
107 // m_bShowMenuStatus = FALSE; // Don't show toolbar or menu status
\r
108 // m_bUseReBar = FALSE; // Don't use rebars
\r
109 // m_bUseThemes = FALSE; // Don't use themes
\r
110 // m_bUseToolBar = FALSE; // Don't use a toolbar
\r
111 // m_bUseCustomDraw = FALSE; // Don't use custom draw for menu items
\r
113 // call the base class function
\r
114 CFrame::OnCreate();
\r
115 m_View.SetFixedWidth(TRUE);
\r
116 m_View.SetOwnerDraw(TRUE);
\r
119 void CMainFrame::OnInitialUpdate()
\r
121 // Add some tabs to the tab control
\r
122 m_View.AddTabPage(new CViewClasses, _T("Classes"), IDI_CLASSVIEW);
\r
123 m_View.AddTabPage(new CViewFiles, _T("Files"), IDI_FILEVIEW);
\r
124 m_View.AddTabPage(new CViewClasses, _T("Classes"), IDI_CLASSVIEW);
\r
125 m_View.AddTabPage(new CViewFiles, _T("Files"), IDI_FILEVIEW);
\r
126 m_View.SelectPage(0);
\r
128 // PreCreate initially set the window as invisible, so show it now.
\r
132 void CMainFrame::OnShowButtons()
\r
134 BOOL bShow = m_View.GetShowButtons();
\r
135 m_View.SetShowButtons(!bShow);
\r
136 UINT uCheck = bShow? MF_UNCHECKED : MF_CHECKED;
\r
137 ::CheckMenuItem(GetFrameMenu(), IDM_TAB_BUTTONS, uCheck);
\r
138 m_View.RedrawWindow();
\r
141 void CMainFrame::OnTabsAtTop()
\r
143 BOOL bTop = m_View.GetTabsAtTop();
\r
144 m_View.SetTabsAtTop(!bTop);
\r
146 UINT uCheck = (bTop)? MF_UNCHECKED : MF_CHECKED;
\r
147 ::CheckMenuItem(GetFrameMenu(), IDM_TAB_TOP, uCheck);
\r
150 void CMainFrame::PreCreate(CREATESTRUCT &cs)
\r
152 // Call the base class function first
\r
153 CFrame::PreCreate(cs);
\r
155 // Hide the window initially by removing the WS_VISIBLE style
\r
156 cs.style &= ~WS_VISIBLE;
\r
159 void CMainFrame::SetupToolBar()
\r
161 // Set the Resource IDs for the toolbar buttons
\r
162 AddToolBarButton( IDM_FILE_NEW );
\r
163 AddToolBarButton( IDM_FILE_OPEN, FALSE );
\r
164 AddToolBarButton( IDM_FILE_SAVE, FALSE );
\r
166 AddToolBarButton( 0 ); // Separator
\r
167 AddToolBarButton( IDM_EDIT_CUT, FALSE );
\r
168 AddToolBarButton( IDM_EDIT_COPY, FALSE );
\r
169 AddToolBarButton( IDM_EDIT_PASTE, FALSE );
\r
171 AddToolBarButton( 0 ); // Separator
\r
172 AddToolBarButton( IDM_FILE_PRINT, FALSE );
\r
174 AddToolBarButton( 0 ); // Separator
\r
175 AddToolBarButton( IDM_HELP_ABOUT );
\r
177 // Set the Checkmarks in the menu
\r
178 ::CheckMenuItem(GetFrameMenu(), IDM_TAB_BUTTONS, MF_UNCHECKED);
\r
180 // Add some extra icons for menu items
\r
181 AddMenuIcon(IDM_NEW_FILES, ::LoadIcon(GetApp()->GetInstanceHandle(), MAKEINTRESOURCE(IDI_FILEVIEW)));
\r
182 AddMenuIcon(IDM_NEW_CLASSES, ::LoadIcon(GetApp()->GetInstanceHandle(), MAKEINTRESOURCE(IDI_CLASSVIEW)));
\r
185 LRESULT CMainFrame::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
189 // Add case statements for each messages to be handled here
\r
192 // pass unhandled messages on for default processing
\r
193 return WndProcDefault(uMsg, wParam, lParam);
\r