123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594 |
- // 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面
- // (“Fluent UI”)。该示例仅供参考,
- // 用以补充《Microsoft 基础类参考》和
- // MFC C++ 库软件随附的相关电子文档。
- // 复制、使用或分发 Fluent UI 的许可条款是单独提供的。
- // 若要了解有关 Fluent UI 许可计划的详细信息,请访问
- // https://go.microsoft.com/fwlink/?LinkId=238214.
- //
- // 版权所有(C) Microsoft Corporation
- // 保留所有权利。
- // MainFrm.cpp: CMainFrame 类的实现
- //
- #include "stdafx.h"
- #include "IDE.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- // CMainFrame
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx)
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx)
- ON_WM_CREATE()
- ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnApplicationLook)
- ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnUpdateApplicationLook)
- ON_COMMAND(ID_VIEW_CLASS_BAR, &CMainFrame::OnClassViewCaptionBar)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CLASS_BAR, &CMainFrame::OnUpdateClassViewCaptionBar)
- ON_COMMAND(ID_TOOLS_OPTIONS, &CMainFrame::OnOptions)
- ON_COMMAND(ID_VIEW_FILEVIEW, &CMainFrame::OnViewFileView)
- ON_UPDATE_COMMAND_UI(ID_VIEW_FILEVIEW, &CMainFrame::OnUpdateViewFileView)
- ON_COMMAND(ID_VIEW_CLASSVIEW, &CMainFrame::OnViewClassView)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CLASSVIEW, &CMainFrame::OnUpdateViewClassView)
- ON_COMMAND(ID_VIEW_OUTPUTWND, &CMainFrame::OnViewOutputWindow)
- ON_UPDATE_COMMAND_UI(ID_VIEW_OUTPUTWND, &CMainFrame::OnUpdateViewOutputWindow)
- ON_COMMAND(ID_VIEW_PROPERTIESWND, &CMainFrame::OnViewPropertiesWindow)
- ON_UPDATE_COMMAND_UI(ID_VIEW_PROPERTIESWND, &CMainFrame::OnUpdateViewPropertiesWindow)
- ON_COMMAND(ID_FILE_PRINT, &CMainFrame::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, &CMainFrame::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CMainFrame::OnFilePrintPreview)
- ON_UPDATE_COMMAND_UI(ID_FILE_PRINT_PREVIEW, &CMainFrame::OnUpdateFilePrintPreview)
- ON_WM_SETTINGCHANGE()
- ON_WM_GETMINMAXINFO()
- ON_COMMAND(ID_VIEW_FILE_BAR, &CMainFrame::OnViewFileBar)
- ON_UPDATE_COMMAND_UI(ID_VIEW_FILE_BAR, &CMainFrame::OnUpdateViewFileBar)
- ON_COMMAND(ID_VIEW_PROPERTY_BAR, &CMainFrame::OnViewPropertyBar)
- ON_UPDATE_COMMAND_UI(ID_VIEW_PROPERTY_BAR, &CMainFrame::OnUpdateViewPropertyBar)
- ON_COMMAND(ID_VIEW_OUTPUT_BAR, &CMainFrame::OnViewOutputBar)
- ON_UPDATE_COMMAND_UI(ID_VIEW_OUTPUT_BAR, &CMainFrame::OnUpdateViewOutputBar)
- END_MESSAGE_MAP()
- // CMainFrame 构造/析构
- CMainFrame::CMainFrame() noexcept
- {
- // TODO: 在此添加成员初始化代码
- theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_VS_2008);
- }
- CMainFrame::~CMainFrame()
- {
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWndEx::OnCreate(lpCreateStruct) == -1)
- return -1;
- BOOL bNameValid;
- m_wndRibbonBar.Create(this);
- m_wndRibbonBar.LoadFromResource(IDR_RIBBON);
- #if !__QUICKACCESS_COMMAND__
- CMFCRibbonQuickAccessToolBar* pQAToolbar = m_wndRibbonBar.GetQuickAccessToolbar();
- pQAToolbar->RemoveAll();
- #endif
- if (!m_wndStatusBar.Create(this))
- {
- TRACE0("未能创建状态栏\n");
- return -1; // 未能创建
- }
- CString strTitlePane1;
- CString strTitlePane2;
- bNameValid = strTitlePane1.LoadString(IDS_STATUS_PANE1);
- ASSERT(bNameValid);
- bNameValid = strTitlePane2.LoadString(IDS_STATUS_PANE2);
- ASSERT(bNameValid);
- m_wndStatusBar.AddElement(new CMFCRibbonStatusBarPane(ID_STATUSBAR_PANE1, strTitlePane1, TRUE), strTitlePane1);
- m_wndStatusBar.AddExtendedElement(new CMFCRibbonStatusBarPane(ID_STATUSBAR_PANE2, strTitlePane2, TRUE), strTitlePane2);
- // 启用 Visual Studio 2005 样式停靠窗口行为
- CDockingManager::SetDockingMode(DT_SMART);
- // 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为
- EnableAutoHidePanes(CBRS_ALIGN_ANY);
- #if __OUTLOOKBAR__
- // 导航窗格将创建在左侧,因此将暂时禁用左侧的停靠:
- EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM | CBRS_ALIGN_RIGHT);
- // 创建并设置“Outlook”导航栏:
- if (!CreateOutlookBar(m_wndNavigationBar, ID_VIEW_NAVIGATION, m_wndTree, m_wndCalendar, 250))
- {
- TRACE0("未能创建导航窗格\n");
- return -1; // 未能创建
- }
- #endif
- #if __CAPTIONBAR__
- // 创建标题栏:
- if (!CreateCaptionBar())
- {
- TRACE0("未能创建标题栏\n");
- return -1; // 未能创建
- }
- #endif
- #if __OUTLOOKBAR__
- // 已创建 Outlook 栏,应允许在左侧停靠。
- EnableDocking(CBRS_ALIGN_LEFT);
- EnableAutoHidePanes(CBRS_ALIGN_RIGHT);
- #endif
- // 加载菜单项图像(不在任何标准工具栏上):
- CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0);
- // 创建停靠窗口
- if (!CreateDockingWindows())
- {
- TRACE0("未能创建停靠窗口\n");
- return -1;
- }
- m_wndFileView.EnableDocking(CBRS_ALIGN_ANY);
- m_wndClassView.EnableDocking(CBRS_ALIGN_ANY);
- DockPane(&m_wndFileView);
- CDockablePane* pTabbedBar = nullptr;
- m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar);
- m_wndOutput.EnableDocking(CBRS_ALIGN_ANY);
- DockPane(&m_wndOutput);
- m_wndProperties.EnableDocking(CBRS_ALIGN_ANY);
- DockPane(&m_wndProperties);
- // 基于持久值设置视觉管理器和样式
- OnApplicationLook(theApp.m_nAppLook);
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CFrameWndEx::PreCreateWindow(cs) )
- return FALSE;
- // TODO: 在此处通过修改
- // CREATESTRUCT cs 来修改窗口类或样式
- return TRUE;
- }
- BOOL CMainFrame::CreateDockingWindows()
- {
- BOOL bNameValid;
- // 创建类视图
- CString strClassView;
- bNameValid = strClassView.LoadString(IDS_CLASS_VIEW);
- ASSERT(bNameValid);
- if (!m_wndClassView.Create(strClassView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_CLASSVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
- {
- TRACE0("未能创建“类视图”窗口\n");
- return FALSE; // 未能创建
- }
- // 创建文件视图
- CString strFileView;
- bNameValid = strFileView.LoadString(IDS_FILE_VIEW);
- ASSERT(bNameValid);
- if (!m_wndFileView.Create(strFileView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_FILEVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT| CBRS_FLOAT_MULTI))
- {
- TRACE0("未能创建“文件视图”窗口\n");
- return FALSE; // 未能创建
- }
- // 创建输出窗口
- CString strOutputWnd;
- bNameValid = strOutputWnd.LoadString(IDS_OUTPUT_WND);
- ASSERT(bNameValid);
- if (!m_wndOutput.Create(strOutputWnd, this, CRect(0, 0, 100, 100), TRUE, ID_VIEW_OUTPUTWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI))
- {
- TRACE0("未能创建输出窗口\n");
- return FALSE; // 未能创建
- }
- // 创建属性窗口
- CString strPropertiesWnd;
- bNameValid = strPropertiesWnd.LoadString(IDS_PROPERTIES_WND);
- ASSERT(bNameValid);
- if (!m_wndProperties.Create(strPropertiesWnd, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIESWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI))
- {
- TRACE0("未能创建“属性”窗口\n");
- return FALSE; // 未能创建
- }
- SetDockingWindowIcons(theApp.m_bHiColorIcons);
- return TRUE;
- }
- void CMainFrame::SetDockingWindowIcons(BOOL bHiColorIcons)
- {
- HICON hFileViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_FILE_VIEW_HC : IDI_FILE_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0);
- m_wndFileView.SetIcon(hFileViewIcon, FALSE);
- HICON hClassViewIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_CLASS_VIEW_HC : IDI_CLASS_VIEW), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0);
- m_wndClassView.SetIcon(hClassViewIcon, FALSE);
- HICON hOutputBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_OUTPUT_WND_HC : IDI_OUTPUT_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0);
- m_wndOutput.SetIcon(hOutputBarIcon, FALSE);
- HICON hPropertiesBarIcon = (HICON) ::LoadImage(::AfxGetResourceHandle(), MAKEINTRESOURCE(bHiColorIcons ? IDI_PROPERTIES_WND_HC : IDI_PROPERTIES_WND), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), 0);
- m_wndProperties.SetIcon(hPropertiesBarIcon, FALSE);
- }
- #if __OUTLOOKBAR__
- BOOL CMainFrame::CreateOutlookBar(CMFCOutlookBar& bar, UINT uiID, CMFCShellTreeCtrl& tree, CCalendarBar& calendar, int nInitialWidth)
- {
- bar.SetMode2003();
- BOOL bNameValid;
- CString strTemp;
- bNameValid = strTemp.LoadString(IDS_SHORTCUTS);
- ASSERT(bNameValid);
- if (!bar.Create(strTemp, this, CRect(0, 0, nInitialWidth, 32000), uiID, WS_CHILD | WS_VISIBLE | CBRS_LEFT))
- {
- return FALSE; // 未能创建
- }
- CMFCOutlookBarTabCtrl* pOutlookBar = (CMFCOutlookBarTabCtrl*)bar.GetUnderlyingWindow();
- if (pOutlookBar == nullptr)
- {
- ASSERT(FALSE);
- return FALSE;
- }
- pOutlookBar->EnableInPlaceEdit(TRUE);
- static UINT uiPageID = 1;
- // 可浮动,可自动隐藏,可调整大小,但不能关闭
- DWORD dwStyle = AFX_CBRS_FLOAT | AFX_CBRS_AUTOHIDE | AFX_CBRS_RESIZE;
- CRect rectDummy(0, 0, 0, 0);
- const DWORD dwTreeStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS;
- tree.Create(dwTreeStyle, rectDummy, &bar, 1200);
- bNameValid = strTemp.LoadString(IDS_FOLDERS);
- ASSERT(bNameValid);
- pOutlookBar->AddControl(&tree, strTemp, 2, TRUE, dwStyle);
- calendar.Create(rectDummy, &bar, 1201);
- bNameValid = strTemp.LoadString(IDS_CALENDAR);
- ASSERT(bNameValid);
- pOutlookBar->AddControl(&calendar, strTemp, 3, TRUE, dwStyle);
- bar.SetPaneStyle(bar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- pOutlookBar->SetImageList(theApp.m_bHiColorIcons ? IDB_PAGES_HC : IDB_PAGES, 24);
- pOutlookBar->SetToolbarImageList(theApp.m_bHiColorIcons ? IDB_PAGES_SMALL_HC : IDB_PAGES_SMALL, 16);
- pOutlookBar->RecalcLayout();
- BOOL bAnimation = theApp.GetInt(_T("OutlookAnimation"), TRUE);
- CMFCOutlookBarTabCtrl::EnableAnimation(bAnimation);
- bar.SetButtonsFont(&afxGlobalData.fontBold);
- return TRUE;
- }
- #endif
- #if __CAPTIONBAR__
- BOOL CMainFrame::CreateCaptionBar()
- {
- if (!m_wndCaptionBar.Create(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, this, ID_VIEW_CAPTION_BAR, -1, TRUE))
- {
- TRACE0("未能创建标题栏\n");
- return FALSE;
- }
- BOOL bNameValid;
- CString strTemp, strTemp2;
- bNameValid = strTemp.LoadString(IDS_CAPTION_BUTTON);
- ASSERT(bNameValid);
- m_wndCaptionBar.SetButton(strTemp, ID_TOOLS_OPTIONS, CMFCCaptionBar::ALIGN_LEFT, FALSE);
- bNameValid = strTemp.LoadString(IDS_CAPTION_BUTTON_TIP);
- ASSERT(bNameValid);
- m_wndCaptionBar.SetButtonToolTip(strTemp);
- bNameValid = strTemp.LoadString(IDS_CAPTION_TEXT);
- ASSERT(bNameValid);
- m_wndCaptionBar.SetText(strTemp, CMFCCaptionBar::ALIGN_LEFT);
- m_wndCaptionBar.SetBitmap(IDB_INFO, RGB(255, 255, 255), FALSE, CMFCCaptionBar::ALIGN_LEFT);
- bNameValid = strTemp.LoadString(IDS_CAPTION_IMAGE_TIP);
- ASSERT(bNameValid);
- bNameValid = strTemp2.LoadString(IDS_CAPTION_IMAGE_TEXT);
- ASSERT(bNameValid);
- m_wndCaptionBar.SetImageToolTip(strTemp, strTemp2);
- return TRUE;
- }
- #endif
- // CMainFrame 诊断
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CFrameWndEx::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CFrameWndEx::Dump(dc);
- }
- #endif //_DEBUG
- // CMainFrame 消息处理程序
- void CMainFrame::OnApplicationLook(UINT id)
- {
- CWaitCursor wait;
- theApp.m_nAppLook = id;
- switch (theApp.m_nAppLook)
- {
- case ID_VIEW_APPLOOK_WIN_2000:
- CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager));
- m_wndRibbonBar.SetWindows7Look(FALSE);
- break;
- case ID_VIEW_APPLOOK_OFF_XP:
- CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP));
- m_wndRibbonBar.SetWindows7Look(FALSE);
- break;
- case ID_VIEW_APPLOOK_WIN_XP:
- CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE;
- CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
- m_wndRibbonBar.SetWindows7Look(FALSE);
- break;
- case ID_VIEW_APPLOOK_OFF_2003:
- CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003));
- CDockingManager::SetDockingMode(DT_SMART);
- m_wndRibbonBar.SetWindows7Look(FALSE);
- break;
- case ID_VIEW_APPLOOK_VS_2005:
- CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005));
- CDockingManager::SetDockingMode(DT_SMART);
- m_wndRibbonBar.SetWindows7Look(FALSE);
- break;
- case ID_VIEW_APPLOOK_VS_2008:
- CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2008));
- CDockingManager::SetDockingMode(DT_SMART);
- m_wndRibbonBar.SetWindows7Look(FALSE);
- break;
- case ID_VIEW_APPLOOK_WINDOWS_7:
- CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows7));
- CDockingManager::SetDockingMode(DT_SMART);
- m_wndRibbonBar.SetWindows7Look(TRUE);
- break;
- default:
- switch (theApp.m_nAppLook)
- {
- case ID_VIEW_APPLOOK_OFF_2007_BLUE:
- CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue);
- break;
- case ID_VIEW_APPLOOK_OFF_2007_BLACK:
- CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack);
- break;
- case ID_VIEW_APPLOOK_OFF_2007_SILVER:
- CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver);
- break;
- case ID_VIEW_APPLOOK_OFF_2007_AQUA:
- CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua);
- break;
- }
- CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007));
- CDockingManager::SetDockingMode(DT_SMART);
- m_wndRibbonBar.SetWindows7Look(FALSE);
- }
- m_wndOutput.UpdateFonts();
- RedrawWindow(nullptr, nullptr, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE);
- theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook);
- }
- void CMainFrame::OnUpdateApplicationLook(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(theApp.m_nAppLook == pCmdUI->m_nID);
- }
- void CMainFrame::OnClassViewCaptionBar()
- {
- #if __CAPTIONBAR__
- m_wndCaptionBar.ShowWindow(m_wndCaptionBar.IsVisible() ? SW_HIDE : SW_SHOW);
- #endif
- #if 1
- // 类视图;
- BOOL bVisible = m_wndClassView.IsVisible();
- m_wndClassView.ShowPane(!bVisible, FALSE, !bVisible);
- #endif
- RecalcLayout(FALSE);
- }
- void CMainFrame::OnUpdateClassViewCaptionBar(CCmdUI* pCmdUI)
- {
- #if __CAPTIONBAR__
- pCmdUI->SetCheck(m_wndCaptionBar.IsVisible());
- #endif
- #if 1
- pCmdUI->SetCheck(m_wndClassView.IsVisible());
- #endif
- }
- void CMainFrame::OnOptions()
- {
- CMFCRibbonCustomizeDialog *pOptionsDlg = new CMFCRibbonCustomizeDialog(this, &m_wndRibbonBar);
- ASSERT(pOptionsDlg != nullptr);
- pOptionsDlg->DoModal();
- delete pOptionsDlg;
- }
- void CMainFrame::OnViewFileView()
- {
- // 显示或激活窗格,具体取决于当前状态。
- // 只能通过窗格帧上的 [x] 按钮关闭窗格。
- m_wndFileView.ShowPane(TRUE, FALSE, TRUE);
- m_wndFileView.SetFocus();
- }
- void CMainFrame::OnUpdateViewFileView(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
- }
- void CMainFrame::OnViewClassView()
- {
- // 显示或激活窗格,具体取决于当前状态。
- // 只能通过窗格帧上的 [x] 按钮关闭窗格。
- m_wndClassView.ShowPane(TRUE, FALSE, TRUE);
- m_wndClassView.SetFocus();
- }
- void CMainFrame::OnUpdateViewClassView(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
- }
- void CMainFrame::OnViewOutputWindow()
- {
- // 显示或激活窗格,具体取决于当前状态。
- // 只能通过窗格帧上的 [x] 按钮关闭窗格。
- m_wndOutput.ShowPane(TRUE, FALSE, TRUE);
- m_wndOutput.SetFocus();
- }
- void CMainFrame::OnUpdateViewOutputWindow(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
- }
- void CMainFrame::OnViewPropertiesWindow()
- {
- // 显示或激活窗格,具体取决于当前状态。
- // 只能通过窗格帧上的 [x] 按钮关闭窗格。
- m_wndProperties.ShowPane(TRUE, FALSE, TRUE);
- m_wndProperties.SetFocus();
- }
- void CMainFrame::OnUpdateViewPropertiesWindow(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
- }
- void CMainFrame::OnFilePrint()
- {
- if (IsPrintPreview())
- {
- PostMessage(WM_COMMAND, AFX_ID_PREVIEW_PRINT);
- }
- }
- void CMainFrame::OnFilePrintPreview()
- {
- if (IsPrintPreview())
- {
- PostMessage(WM_COMMAND, AFX_ID_PREVIEW_CLOSE); // 强制关闭“打印预览”模式
- }
- }
- void CMainFrame::OnUpdateFilePrintPreview(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(IsPrintPreview());
- }
- void CMainFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
- {
- CFrameWndEx::OnSettingChange(uFlags, lpszSection);
- m_wndOutput.UpdateFonts();
- }
- void CMainFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
- {
- // TODO: 在此添加消息处理程序代码和/或调用默认值
- // 640*480//800*600
- // 设置窗口最小范围;
- lpMMI->ptMinTrackSize.x = 800;
- lpMMI->ptMinTrackSize.y = 600;
- CFrameWndEx::OnGetMinMaxInfo(lpMMI);
- }
- void CMainFrame::OnViewFileBar()
- {
- // TODO: 在此添加命令处理程序代码
- // 类视图;
- BOOL bVisible = m_wndFileView.IsVisible();
- m_wndFileView.ShowPane(!bVisible, FALSE, !bVisible);
- RecalcLayout(FALSE);
- }
- void CMainFrame::OnUpdateViewFileBar(CCmdUI *pCmdUI)
- {
- // TODO: 在此添加命令更新用户界面处理程序代码
- pCmdUI->SetCheck(m_wndFileView.IsVisible());
- }
- void CMainFrame::OnViewPropertyBar()
- {
- // TODO: 在此添加命令处理程序代码
- BOOL bVisible = m_wndProperties.IsVisible();
- m_wndProperties.ShowPane(!bVisible, FALSE, !bVisible);
- RecalcLayout(FALSE);
- }
- void CMainFrame::OnUpdateViewPropertyBar(CCmdUI *pCmdUI)
- {
- // TODO: 在此添加命令更新用户界面处理程序代码
- pCmdUI->SetCheck(m_wndProperties.IsVisible());
- }
- void CMainFrame::OnViewOutputBar()
- {
- // TODO: 在此添加命令处理程序代码
- BOOL bVisible = m_wndOutput.IsVisible();
- m_wndOutput.ShowPane(!bVisible, FALSE, !bVisible);
- RecalcLayout(FALSE);
- }
- void CMainFrame::OnUpdateViewOutputBar(CCmdUI *pCmdUI)
- {
- // TODO: 在此添加命令更新用户界面处理程序代码
- pCmdUI->SetCheck(m_wndOutput.IsVisible());
- }
|