// [!output CHILD_FRAME_IMPL] : implementation of the [!output CHILD_FRAME_CLASS] class // #include "stdafx.h" #include "[!output APP_HEADER]" #include "[!output CHILD_FRAME_HEADER]" [!if PROJECT_STYLE_EXPLORER] #include "[!output TREE_VIEW_HEADER]" #include "[!output VIEW_HEADER]" [!endif] #ifdef _DEBUG #define new DEBUG_NEW #endif // [!output CHILD_FRAME_CLASS] IMPLEMENT_DYNCREATE([!output CHILD_FRAME_CLASS], [!output CHILD_FRAME_BASE_CLASS]) BEGIN_MESSAGE_MAP([!output CHILD_FRAME_CLASS], [!output CHILD_FRAME_BASE_CLASS]) [!if !DOCVIEW] ON_COMMAND(ID_FILE_CLOSE, &[!output CHILD_FRAME_CLASS]::OnFileClose) ON_WM_SETFOCUS() [!endif] [!if !DOCVIEW || APP_TYPE_MDI || TOOLBAR_STYLE_REBAR] ON_WM_CREATE() [!endif] [!if PROJECT_STYLE_EXPLORER] [!if LIST_VIEW] ON_UPDATE_COMMAND_UI_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, &[!output CHILD_FRAME_CLASS]::OnUpdateViewStyles) ON_COMMAND_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, &[!output CHILD_FRAME_CLASS]::OnViewStyle) [!endif] [!endif] END_MESSAGE_MAP() // [!output CHILD_FRAME_CLASS] construction/destruction [!output CHILD_FRAME_CLASS]::[!output CHILD_FRAME_CLASS]() { [!if ACCESSIBILITY] EnableActiveAccessibility(); [!endif] // TODO: add member initialization code here } [!output CHILD_FRAME_CLASS]::~[!output CHILD_FRAME_CLASS]() { } [!if APP_TYPE_MDI && SPLITTER] BOOL [!output CHILD_FRAME_CLASS]::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext) { [!if PROJECT_STYLE_EXPLORER] // create splitter window if (!m_wndSplitter.CreateStatic(this, 1, 2)) return FALSE; if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS([!output TREE_VIEW_CLASS]), CSize(100, 100), pContext) || !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS([!output VIEW_CLASS]), CSize(100, 100), pContext)) { m_wndSplitter.DestroyWindow(); return FALSE; } return TRUE; [!else] [!if HTML_VIEW || HTML_EDITVIEW] return m_wndSplitter.Create(this, 2, 2, // TODO: adjust the number of rows, columns CSize(10, 10), // TODO: adjust the minimum pane size pContext, WS_CHILD | WS_VISIBLE | SPLS_DYNAMIC_SPLIT); [!else] return m_wndSplitter.Create(this, 2, 2, // TODO: adjust the number of rows, columns CSize(10, 10), // TODO: adjust the minimum pane size pContext); [!endif] [!endif] } [!else] [!if PROJECT_STYLE_EXPLORER] BOOL [!output CHILD_FRAME_CLASS]::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext) { // create splitter window if (!m_wndSplitter.CreateStatic(this, 1, 2)) return FALSE; if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS([!output TREE_VIEW_CLASS]), CSize(100, 100), pContext) || !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS([!output VIEW_CLASS]), CSize(100, 100), pContext)) { m_wndSplitter.DestroyWindow(); return FALSE; } return TRUE; } [!endif] [!endif] BOOL [!output CHILD_FRAME_CLASS]::PreCreateWindow(CREATESTRUCT& cs) { [!if MDITABS] // Make sure view is maximum size to eliminate // flicker when switching tabs. cs.x = cs.y = 0; cs.cx = cs.cy = 32767; [!endif] // TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs if( ![!output CHILD_FRAME_BASE_CLASS]::PreCreateWindow(cs) ) return FALSE; [!if !CHILD_FRAME_DEFAULT_STYLES] cs.style = WS_CHILD | WS_VISIBLE | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | FWS_ADDTOTITLE[!output CHILD_FRAME_STYLE_FLAGS]; [!endif] [!if !DOCVIEW] cs.dwExStyle &= ~WS_EX_CLIENTEDGE; cs.lpszClass = AfxRegisterWndClass(0); [!endif] return TRUE; } [!if MDITABS] void [!output CHILD_FRAME_CLASS]::ActivateFrame(int nCmdShow) { if (GetParent()->GetWindow(GW_CHILD) == this) { nCmdShow = SW_SHOWMAXIMIZED; } [!output CHILD_FRAME_BASE_CLASS]::ActivateFrame(nCmdShow); } [!endif] // [!output CHILD_FRAME_CLASS] diagnostics #ifdef _DEBUG void [!output CHILD_FRAME_CLASS]::AssertValid() const { [!output CHILD_FRAME_BASE_CLASS]::AssertValid(); } void [!output CHILD_FRAME_CLASS]::Dump(CDumpContext& dc) const { [!output CHILD_FRAME_BASE_CLASS]::Dump(dc); } #endif //_DEBUG // [!output CHILD_FRAME_CLASS] message handlers [!if PROJECT_STYLE_EXPLORER] [!if LIST_VIEW] [!output VIEW_CLASS]* [!output CHILD_FRAME_CLASS]::GetRightPane() { CWnd* pWnd = m_wndSplitter.GetPane(0, 1); [!output VIEW_CLASS]* pView = DYNAMIC_DOWNCAST([!output VIEW_CLASS], pWnd); return pView; } void [!output CHILD_FRAME_CLASS]::OnUpdateViewStyles(CCmdUI* pCmdUI) { // TODO: customize or extend this code to handle choices on the View menu. [!output VIEW_CLASS]* pView = GetRightPane(); // if the right-hand pane hasn't been created or isn't a view, disable commands in our range if (pView == NULL) pCmdUI->Enable(FALSE); else { DWORD dwStyle = pView->GetStyle() & LVS_TYPEMASK; // if the command is ID_VIEW_LINEUP, only enable command // when we're in LVS_ICON or LVS_SMALLICON mode if (pCmdUI->m_nID == ID_VIEW_LINEUP) { if (dwStyle == LVS_ICON || dwStyle == LVS_SMALLICON) pCmdUI->Enable(); else pCmdUI->Enable(FALSE); } else { // otherwise, use dots to reflect the style of the view pCmdUI->Enable(); BOOL bChecked = FALSE; switch (pCmdUI->m_nID) { case ID_VIEW_DETAILS: bChecked = (dwStyle == LVS_REPORT); break; case ID_VIEW_SMALLICON: bChecked = (dwStyle == LVS_SMALLICON); break; case ID_VIEW_LARGEICON: bChecked = (dwStyle == LVS_ICON); break; case ID_VIEW_LIST: bChecked = (dwStyle == LVS_LIST); break; default: bChecked = FALSE; break; } pCmdUI->SetRadio(bChecked ? 1 : 0); } } } void [!output CHILD_FRAME_CLASS]::OnViewStyle(UINT nCommandID) { // TODO: customize or extend this code to handle choices on the View menu. [!output VIEW_CLASS]* pView = GetRightPane(); // if the right-hand pane has been created and is a [!output VIEW_CLASS], process the menu commands... if (pView != NULL) { int nStyle = -1; switch (nCommandID) { case ID_VIEW_LINEUP: { // ask the list control to snap to grid CListCtrl& refListCtrl = pView->GetListCtrl(); refListCtrl.Arrange(LVA_SNAPTOGRID); } break; // other commands change the style on the list control case ID_VIEW_DETAILS: nStyle = LVS_REPORT; break; case ID_VIEW_SMALLICON: nStyle = LVS_SMALLICON; break; case ID_VIEW_LARGEICON: nStyle = LVS_ICON; break; case ID_VIEW_LIST: nStyle = LVS_LIST; break; } // change the style; window will repaint automatically if (nStyle != -1) pView->ModifyStyle(LVS_TYPEMASK, nStyle); } } [!endif] [!endif] [!if !DOCVIEW] void [!output CHILD_FRAME_CLASS]::OnFileClose() { // To close the frame, just send a WM_CLOSE, which is the equivalent // choosing close from the system menu. SendMessage(WM_CLOSE); } void [!output CHILD_FRAME_CLASS]::OnSetFocus(CWnd* pOldWnd) { CMDIChildWnd::OnSetFocus(pOldWnd); m_wndView.SetFocus(); } BOOL [!output CHILD_FRAME_CLASS]::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) { // let the view have first crack at the command if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) return TRUE; // otherwise, do default handling return CMDIChildWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); } [!endif] [!if !DOCVIEW || APP_TYPE_MDI || TOOLBAR_STYLE_REBAR] int [!output CHILD_FRAME_CLASS]::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1) return -1; [!if !DOCVIEW] // create a view to occupy the client area of the frame if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL)) { TRACE0("Failed to create view window\n"); return -1; } [!endif] [!if APP_TYPE_MDI] OnUpdateMDIChildrenTheme(); [!endif] return 0; } [!endif] [!if APP_TYPE_MDI] void [!output CHILD_FRAME_CLASS]::OnUpdateMDIChildrenTheme() { CXTPMDIFrameWnd* pParentFrame = (CXTPMDIFrameWnd*)GetParentFrame(); _ASSERTE(NULL != pParentFrame); CXTPCommandBars* pParentCommandBars = pParentFrame->GetCommandBars(); _ASSERTE(NULL != pParentCommandBars); EnableFrameTheme(this, pParentCommandBars->GetPaintManager()); } [!endif]