Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

264 lines
7.0 KiB

  1. ///+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: mainfrm.h
  8. //
  9. //--------------------------------------------------------------------------
  10. // MainFrm.h : interface of the CMainFrame class
  11. //
  12. /////////////////////////////////////////////////////////////////////////////
  13. #ifndef __DOCKSITE_H__
  14. #include "docksite.h"
  15. #endif
  16. //forward prototypes
  17. class CAMCView;
  18. class CAMCTreeView;
  19. class CMenuBar;
  20. class CMMCToolBar;
  21. class CToolbarTracker;
  22. #ifndef _STATBAR_H
  23. #include "statbar.h"
  24. #endif
  25. #include "MDIClint.h"
  26. #include "conframe.h" // for CConsoleFrame
  27. #define ID_MENUBAR 0x1001
  28. #define ID_TOOLBAR 0x1002
  29. class CMainFrame : public CMDIFrameWnd, public CConsoleFrame, public CTiedObject
  30. {
  31. DECLARE_DYNAMIC(CMainFrame)
  32. public:
  33. CMainFrame();
  34. // Attributes
  35. public:
  36. SC ScGetFrame(Frame** ppFrame);
  37. SC ScMaximize();
  38. SC ScMinimize();
  39. SC ScRestore();
  40. SC ScSetPosition(const RECT &rect);
  41. SC ScGetPosition(RECT &rect);
  42. // Operations
  43. public:
  44. void NotifyMenuChanged ();
  45. void OnIdle ();
  46. void SetInRenameMode(bool b)
  47. {
  48. m_bInRenameMode = b;
  49. }
  50. bool InRenameMode(void) const
  51. {
  52. return m_bInRenameMode;
  53. }
  54. // Overrides
  55. // ClassWizard generated virtual function overrides
  56. //{{AFX_VIRTUAL(CMainFrame)
  57. public:
  58. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  59. virtual BOOL PreTranslateMessage(MSG* pMsg);
  60. virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = NULL, CCreateContext* pContext = NULL);
  61. //}}AFX_VIRTUAL
  62. // Implementation
  63. public:
  64. virtual ~CMainFrame();
  65. #ifdef _DEBUG
  66. virtual void AssertValid() const;
  67. virtual void Dump(CDumpContext& dc) const;
  68. #endif
  69. virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
  70. virtual void OnUpdateFrameMenu(HMENU hMenuAlt);
  71. public: // control bar embedded members
  72. CMenuBar * m_pMenuBar;
  73. CMMCToolBar* m_pToolBar;
  74. CMDIClientWnd m_wndMDIClient;
  75. //Operations
  76. public:
  77. void RenderDockSites();
  78. bool IsMenuVisible();
  79. void ShowMenu(bool bShow);
  80. void UpdateChildSystemMenus ();
  81. void SetIconEx (HICON hIcon, BOOL fBig);
  82. void SetFocusedChildWnd(CMDIChildWnd* pWnd) { m_pMDIChildWndFocused = pWnd; }
  83. CMDIChildWnd* GetFocusedChildWnd() { return m_pMDIChildWndFocused; }
  84. void SetWindowToNotifyCBChange(HWND hwnd) { m_hwndToNotifyCBChange = hwnd; }
  85. CAMCView* GetActiveAMCView();
  86. HACCEL& GetAccelTable()
  87. {
  88. return (m_hAccelTable);
  89. }
  90. CMenu* GetMenu () const
  91. {
  92. return (CMenu::FromHandle (m_hMenuCurrent));
  93. }
  94. CRebarWnd* GetRebar () const
  95. {
  96. return (m_pRebar->GetRebar());
  97. }
  98. CRebarDockWindow* GetRebarDockWindow()
  99. {
  100. return (m_pRebar);
  101. }
  102. CToolbarTracker* GetToolbarTracker () const
  103. {
  104. return (m_pToolbarTracker);
  105. }
  106. CMenuBar* GetMenuBar() const
  107. {
  108. return (m_pMenuBar);
  109. }
  110. CMMCToolBar* GetMainToolbar()
  111. {
  112. return m_pToolBar;
  113. }
  114. public:
  115. // CConsoleFrame methods
  116. virtual SC ScGetActiveStatusBar (CConsoleStatusBar*& pStatusBar);
  117. virtual SC ScGetActiveConsoleView (CConsoleView*& pConsoleView);
  118. virtual SC ScCreateNewView (CreateNewViewStruct* pcnvs,
  119. bool bEmitScriptEvents = true);
  120. virtual SC ScUpdateAllScopes (LONG lHint, LPARAM lParam);
  121. virtual SC ScGetMenuAccelerators (LPTSTR pBuffer, int cchBuffer);
  122. virtual SC ScShowMMCMenus (bool bShow);
  123. protected: // control bar embedded members
  124. virtual CWnd* GetMessageBar()
  125. { return (NULL); }
  126. HICON GetDefaultIcon () const;
  127. CDockManager<CDockSite> m_DockingManager;
  128. CDockSite m_ToolBarDockSite;
  129. CRebarDockWindow* m_pRebar;
  130. CToolbarTracker* m_pToolbarTracker;
  131. CMDIChildWnd* m_pMDIChildWndFocused;
  132. //Operations
  133. protected:
  134. void AddMainFrameBars(void);
  135. void CommonConstruct(void);
  136. // Generated message map functions
  137. // CODEWORK message reflection not working yet
  138. protected:
  139. //{{AFX_MSG(CMainFrame)
  140. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  141. afx_msg void OnDrawClipboard();
  142. afx_msg void OnChangeCbChain(HWND hWndRemove, HWND hWndAfter);
  143. afx_msg void OnUpdateFilePrint(CCmdUI* pCmdUI);
  144. afx_msg void OnUpdateFilePrintSetup(CCmdUI* pCmdUI);
  145. afx_msg void OnClose();
  146. afx_msg void OnViewToolbar();
  147. afx_msg void OnUpdateViewToolbar(CCmdUI* pCmdUI);
  148. afx_msg void OnSize(UINT nType, int cx, int cy);
  149. afx_msg void OnViewRefresh();
  150. afx_msg void OnUpdateViewRefresh(CCmdUI* pCmdUI);
  151. afx_msg void OnDestroy();
  152. afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
  153. afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
  154. afx_msg void OnConsoleProperties();
  155. afx_msg void OnMove(int x, int y);
  156. afx_msg void OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized );
  157. afx_msg BOOL OnNcActivate(BOOL bActive);
  158. afx_msg void OnNcPaint();
  159. afx_msg void OnPaletteChanged(CWnd* pwndFocus);
  160. afx_msg BOOL OnQueryNewPalette( );
  161. afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
  162. afx_msg LRESULT OnUnInitMenuPopup(WPARAM wParam, LPARAM lParam);
  163. //}}AFX_MSG
  164. #ifdef DBG
  165. afx_msg void OnMMCTraceDialog();
  166. #endif
  167. afx_msg LRESULT OnShowSnapinHelpTopic(WPARAM wParam, LPARAM lParam);
  168. afx_msg LRESULT OnPropertySheetNotify(WPARAM wParam, LPARAM lParam);
  169. afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
  170. afx_msg void OnWindowNew();
  171. DECLARE_MESSAGE_MAP()
  172. // These need to be public so that the app can get to them.
  173. public:
  174. afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
  175. afx_msg void OnHelpTopics();
  176. SC ScOnHelpTopics();
  177. private:
  178. HWND m_hwndNextCB;
  179. HWND m_hwndToNotifyCBChange;
  180. HMENU m_hMenuCurrent;
  181. bool m_bInRenameMode;
  182. bool m_fCurrentlyMinimized;
  183. bool m_fCurrentlyActive;
  184. CString m_strGenericTitle;
  185. CString GetFrameTitle();
  186. CAMCTreeView* _GetActiveAMCTreeView();
  187. void SendMinimizeNotifications (bool fMinimized) const;
  188. };
  189. inline CMainFrame* AMCGetMainWnd()
  190. {
  191. /*
  192. * Note: the dynamic_cast here can fail. Under certain, not understood
  193. * circumstances, AfxGetMainWnd can return a pointer to CTempWnd instead
  194. * of CMainFrame.
  195. *
  196. * Any callers of this function *must* check for a NULL return value.
  197. */
  198. CWnd *pWnd = AfxGetMainWnd();
  199. CMainFrame *pMainFrame = NULL;
  200. try
  201. {
  202. pMainFrame = dynamic_cast<CMainFrame*>(pWnd);
  203. }
  204. catch (...)
  205. {
  206. pMainFrame = NULL;
  207. }
  208. return (pMainFrame);
  209. }
  210. inline CRebarWnd* AMCGetRebar()
  211. {
  212. CMainFrame* pMainFrame = AMCGetMainWnd();
  213. if (NULL == pMainFrame)
  214. return NULL;
  215. return pMainFrame->GetRebar();
  216. }
  217. bool FArePropertySheetsOpen(CString* pstrUserMsg, bool bBringToFrontAndAskToClose = true);
  218. /////////////////////////////////////////////////////////////////////////////