MainFrm.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. // 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面
  2. // (“Fluent UI”)。该示例仅供参考,
  3. // 用以补充《Microsoft 基础类参考》和
  4. // MFC C++ 库软件随附的相关电子文档。
  5. // 复制、使用或分发 Fluent UI 的许可条款是单独提供的。
  6. // 若要了解有关 Fluent UI 许可计划的详细信息,请访问
  7. // https://go.microsoft.com/fwlink/?LinkId=238214.
  8. //
  9. // 版权所有(C) Microsoft Corporation
  10. // 保留所有权利。
  11. // MainFrm.h: CMainFrame 类的接口
  12. //
  13. #pragma once
  14. #include "FileView.h"
  15. #include "ClassView.h"
  16. #include "OutputWnd.h"
  17. #include "IRControlWnd.h"
  18. #include "CalendarBar.h"
  19. #include "Resource.h"
  20. #include "TrayIcon.h"
  21. #define USE_TRAYICON 1
  22. // 状态栏消息;
  23. #define MSG_STATUS_BAR (WM_USER + 101)
  24. class COutlookBar : public CMFCOutlookBar
  25. {
  26. virtual BOOL AllowShowOnPaneMenu() const { return TRUE; }
  27. virtual void GetPaneName(CString& strName) const { BOOL bNameValid = strName.LoadString(IDS_OUTLOOKBAR); ASSERT(bNameValid); if (!bNameValid) strName.Empty(); }
  28. };
  29. class CMainFrame : public CFrameWndEx
  30. {
  31. protected: // 仅从序列化创建
  32. CMainFrame() noexcept;
  33. DECLARE_DYNCREATE(CMainFrame)
  34. // 特性
  35. public:
  36. // 操作
  37. public:
  38. // 重写
  39. public:
  40. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  41. // 实现
  42. public:
  43. virtual ~CMainFrame();
  44. #ifdef _DEBUG
  45. virtual void AssertValid() const;
  46. virtual void Dump(CDumpContext& dc) const;
  47. #endif
  48. protected: // 控件条嵌入成员
  49. CMFCRibbonBar m_wndRibbonBar;
  50. CMFCRibbonApplicationButton m_MainButton;
  51. CMFCToolBarImages m_PanelImages;
  52. CMFCRibbonStatusBar m_wndStatusBar;
  53. #if __DOCKINGBAR__
  54. #if __FC_WIN__
  55. CFileView m_wndFileView;
  56. CClassView m_wndClassView;
  57. #endif
  58. #if __OUT_PUT_WIN__
  59. COutputWnd m_wndOutput;
  60. #endif
  61. CIRControlWnd m_wndIRControl;
  62. #endif
  63. #if __OUTLOOKBAR__
  64. COutlookBar m_wndNavigationBar;
  65. CMFCShellTreeCtrl m_wndTree;
  66. CCalendarBar m_wndCalendar;
  67. #endif
  68. #if __CAPTIONBAR__
  69. CMFCCaptionBar m_wndCaptionBar;
  70. #endif
  71. public:
  72. #if USE_TRAYICON
  73. void InitTrayIcon();
  74. // 托盘是否显示;
  75. BOOL m_isNotify;
  76. // 启动程序时,隐藏或显示对话框,在消息处理程序OnNcPaint()中使用;
  77. BOOL m_bShowNc;
  78. // 是否响应托盘消息;
  79. BOOL m_bNoticeTray;
  80. // 托盘工作类;
  81. ITrayIcon m_trayIcon;
  82. BOOL m_bAutoRuning;
  83. afx_msg LRESULT OnTrayNotification(WPARAM wp, LPARAM lp);
  84. afx_msg LRESULT OnTaskBarCreated(WPARAM wp, LPARAM lp);
  85. void TaskNotifyIcon(); // 托盘的工作内容;
  86. void TrayRight();
  87. #endif
  88. CMFCRibbonButton* GetRibbonButton(int uId) {
  89. return DYNAMIC_DOWNCAST(CMFCRibbonButton, m_wndRibbonBar.FindByID(uId));
  90. }
  91. // 设置状态栏文本;
  92. void SetRibbonStatusBarText(CString strText, int uId) {
  93. if ( IsWindow(m_wndStatusBar) )
  94. {
  95. CMFCRibbonBaseElement *pElement = m_wndStatusBar.FindByID(uId);
  96. if ( pElement )
  97. {
  98. pElement->SetText(strText);
  99. pElement->Redraw();
  100. }
  101. }
  102. }
  103. // 生成的消息映射函数
  104. protected:
  105. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  106. afx_msg void OnApplicationLook(UINT id);
  107. afx_msg void OnUpdateApplicationLook(CCmdUI* pCmdUI);
  108. afx_msg void OnViewCaptionBar();
  109. afx_msg void OnUpdateViewCaptionBar(CCmdUI* pCmdUI);
  110. afx_msg void OnOptions();
  111. afx_msg void OnFilePrint();
  112. afx_msg void OnFilePrintPreview();
  113. afx_msg void OnUpdateFilePrintPreview(CCmdUI* pCmdUI);
  114. afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
  115. afx_msg LRESULT OnMsgStatusBar(WPARAM wParam, LPARAM lParam);
  116. DECLARE_MESSAGE_MAP()
  117. #if __DOCKINGBAR__
  118. BOOL CreateDockingWindows();
  119. void SetDockingWindowIcons(BOOL bHiColorIcons);
  120. #endif
  121. #if __OUTLOOKBAR__
  122. BOOL CreateOutlookBar(CMFCOutlookBar& bar, UINT uiID, CMFCShellTreeCtrl& tree, CCalendarBar& calendar, int nInitialWidth);
  123. #endif
  124. #if __CAPTIONBAR__
  125. BOOL CreateCaptionBar();
  126. #endif
  127. int FindFocusedOutlookWnd(CMFCOutlookBarTabCtrl** ppOutlookWnd);
  128. CMFCOutlookBarTabCtrl* FindOutlookParent(CWnd* pWnd);
  129. CMFCOutlookBarTabCtrl* m_pCurrOutlookWnd;
  130. CMFCOutlookBarPane* m_pCurrOutlookPage;
  131. public:
  132. virtual BOOL PreTranslateMessage(MSG* pMsg);
  133. afx_msg void OnTraymenuExit();
  134. afx_msg void OnClose();
  135. afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
  136. };