Leaked source code of windows server 2003
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.

286 lines
8.2 KiB

  1. /******************************************************************************
  2. Source File: Main Frame.CPP
  3. This implements the main frame class for the application. Since MFC does
  4. so much for us, this file's going to be pretty empty, for a while, at least.
  5. Copyright (c) 1997 by Microsoft Corporaiton. All Rights Reserved.
  6. A Pretty Penny Enterprises Production
  7. Change History:
  8. 02-03-1997 Bob_Kjelgaard@Prodigy.Net Created it
  9. ******************************************************************************/
  10. #include "StdAfx.h"
  11. #if defined(LONG_NAMES)
  12. #include "MiniDriver Developer Studio.H"
  13. #include "Main Frame.h"
  14. #else
  15. #include "MiniDev.H"
  16. #include "MainFrm.H"
  17. #endif
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CMainFrame
  25. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  26. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  27. ON_WM_INITMENU()
  28. //{{AFX_MSG_MAP(CMainFrame)
  29. ON_WM_CREATE()
  30. ON_WM_DESTROY()
  31. //}}AFX_MSG_MAP
  32. // Global help commands
  33. ON_COMMAND(ID_HELP_FINDER, CMDIFrameWnd::OnHelpFinder)
  34. ON_COMMAND(ID_HELP, CMDIFrameWnd::OnHelp)
  35. //ON_COMMAND(ID_CONTEXT_HELP, CMDIFrameWnd::OnContextHelp)
  36. //ON_COMMAND(ID_DEFAULT_HELP, CMDIFrameWnd::OnHelpFinder)
  37. END_MESSAGE_MAP()
  38. static UINT indicators[] = {
  39. ID_SEPARATOR, // status line indicator
  40. ID_INDICATOR_CAPS,
  41. ID_INDICATOR_NUM,
  42. ID_INDICATOR_SCRL,
  43. };
  44. /////////////////////////////////////////////////////////////////////////////
  45. // CMainFrame construction/destruction
  46. CMainFrame::CMainFrame() {
  47. // TODO: add member initialization code here
  48. }
  49. CMainFrame::~CMainFrame() {
  50. }
  51. static TCHAR sacToolBarSettings[] = _TEXT("Tool Bar Settings");
  52. /******************************************************************************
  53. CMainFrame::OnCreate
  54. This is a standard App-Wizard supplied skeleton for the code to be called
  55. when the main window frame is created. Primary modification made to date is
  56. the addition of an additional toolbar, and toolbar state restoration.
  57. ******************************************************************************/
  58. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) {
  59. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  60. return -1;
  61. if (!m_ctbMain.Create(this) || !m_ctbBuild.Create(this, WS_CHILD |
  62. WS_VISIBLE | CBRS_TOP, AFX_IDW_TOOLBAR + 1) ||
  63. !m_ctbMain.LoadToolBar(IDR_MAINFRAME) ||
  64. !m_ctbBuild.LoadToolBar(IDR_GPD_VIEWER)) {
  65. TRACE0("Failed to create toolbars\n");
  66. return -1; // fail to create
  67. }
  68. if (!m_wndStatusBar.Create(this) ||
  69. !m_wndStatusBar.SetIndicators(indicators,
  70. sizeof(indicators)/sizeof(UINT))) {
  71. TRACE0("Failed to create status bar\n");
  72. return -1; // fail to create
  73. }
  74. m_ctbMain.SetBarStyle(m_ctbMain.GetBarStyle() |
  75. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  76. m_ctbBuild.SetBarStyle(m_ctbBuild.GetBarStyle() |
  77. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  78. // Dock the tool bars
  79. m_ctbMain.EnableDocking(CBRS_ALIGN_ANY);
  80. m_ctbBuild.EnableDocking(CBRS_ALIGN_ANY);
  81. EnableDocking(CBRS_ALIGN_ANY);
  82. DockControlBar(&m_ctbMain);
  83. DockControlBar(&m_ctbBuild);
  84. LoadBarState(sacToolBarSettings);
  85. // Replace a bogus, GPD tool bar button with the Search edit box.
  86. CRect cr ;
  87. int nidx = m_ctbBuild.CommandToIndex(ID_BOGUS_SBOX) ;
  88. m_ctbBuild.SetButtonInfo(nidx, ID_BOGUS_SBOX, TBBS_SEPARATOR, GPD_SBOX_WIDTH) ;
  89. m_ctbBuild.GetItemRect(nidx, &cr) ;
  90. if (!m_ctbBuild.ceSearchBox.Create(ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE
  91. | WS_BORDER, cr, &m_ctbBuild, IDC_SearchBox)) {
  92. TRACE0("Failed to create search edit box.\n");
  93. return -1; // fail to create
  94. } ;
  95. return 0;
  96. }
  97. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) {
  98. // TODO: Modify the Window class or styles here by modifying
  99. // the CREATESTRUCT cs
  100. return CMDIFrameWnd::PreCreateWindow(cs);
  101. }
  102. /////////////////////////////////////////////////////////////////////////////
  103. // CMainFrame diagnostics
  104. #ifdef _DEBUG
  105. void CMainFrame::AssertValid() const {
  106. CMDIFrameWnd::AssertValid();
  107. }
  108. void CMainFrame::Dump(CDumpContext& dc) const {
  109. CMDIFrameWnd::Dump(dc);
  110. }
  111. #endif //_DEBUG
  112. /////////////////////////////////////////////////////////////////////////////
  113. // CMainFrame message handlers
  114. void CMainFrame::OnInitMenu(CMenu* pMenu)
  115. {
  116. CMDIFrameWnd::OnInitMenu(pMenu);
  117. //#if defined(NOPOLLO) // CSRUS
  118. // CG: This block added by 'Tip of the Day' component.
  119. {
  120. // TODO: This code adds the "Tip of the Day" menu item
  121. // on the fly. It may be removed after adding the menu
  122. // item to all applicable menu items using the resource
  123. // editor.
  124. // Add Tip of the Day menu item on the fly!
  125. static CMenu* pSubMenu = NULL;
  126. CString strHelp; strHelp.LoadString(CG_IDS_TIPOFTHEDAYHELP);
  127. CString strMenu;
  128. int nMenuCount = pMenu->GetMenuItemCount();
  129. BOOL bFound = FALSE;
  130. for (int i=0; i < nMenuCount; i++)
  131. {
  132. pMenu->GetMenuString(i, strMenu, MF_BYPOSITION);
  133. if (strMenu == strHelp)
  134. {
  135. pSubMenu = pMenu->GetSubMenu(i);
  136. bFound = TRUE;
  137. ASSERT(pSubMenu != NULL);
  138. }
  139. }
  140. CString strTipMenu;
  141. strTipMenu.LoadString(CG_IDS_TIPOFTHEDAYMENU);
  142. if (!bFound)
  143. {
  144. // Help menu is not available. Please add it!
  145. if (pSubMenu == NULL)
  146. {
  147. // The same pop-up menu is shared between mainfrm and frame
  148. // with the doc.
  149. static CMenu popUpMenu;
  150. pSubMenu = &popUpMenu;
  151. pSubMenu->CreatePopupMenu();
  152. pSubMenu->InsertMenu(0, MF_STRING|MF_BYPOSITION,
  153. CG_IDS_TIPOFTHEDAY, strTipMenu);
  154. }
  155. pMenu->AppendMenu(MF_STRING|MF_BYPOSITION|MF_ENABLED|MF_POPUP,
  156. (UINT_PTR)pSubMenu->m_hMenu, strHelp);
  157. DrawMenuBar();
  158. }
  159. else
  160. {
  161. // Check to see if the Tip of the Day menu has already been added.
  162. pSubMenu->GetMenuString(0, strMenu, MF_BYPOSITION);
  163. if (strMenu != strTipMenu)
  164. {
  165. // Tip of the Day submenu has not been added to the
  166. // first position, so add it.
  167. pSubMenu->InsertMenu(0, MF_BYPOSITION); // Separator
  168. pSubMenu->InsertMenu(0, MF_STRING|MF_BYPOSITION,
  169. CG_IDS_TIPOFTHEDAY, strTipMenu);
  170. }
  171. }
  172. }
  173. //#endif
  174. }
  175. /******************************************************************************
  176. CMainFrame::OnDestroy
  177. This member function. called when the frame is to be destroyed, saves the
  178. toolbar states, before proceeding to do the normal kinds of stuff...
  179. ******************************************************************************/
  180. void CMainFrame::OnDestroy() {
  181. // Save the tool bar states.
  182. SaveBarState(sacToolBarSettings);
  183. CMDIFrameWnd::OnDestroy();
  184. }
  185. /******************************************************************************
  186. CMainFrame::GetGPDSearchString
  187. Load the specified string with the search string in the GPD Search string edit
  188. box on the GPD tool bar.
  189. ******************************************************************************/
  190. void CMainFrame::GetGPDSearchString(CString& cstext)
  191. {
  192. m_ctbBuild.ceSearchBox.GetWindowText(cstext) ;
  193. }
  194. /******************************************************************************
  195. CMainFrame::OnViewStatusBar
  196. Show the status bar if the command is not checked. Otherwise, hide the status
  197. bar. Then update the window and the menu command.
  198. ******************************************************************************/
  199. /*
  200. This routine does not check and uncheck the menu command for some reason
  201. and turning off the status bar turns off the GPD tool bar, too. There
  202. are problems because of the ID used for the GPD tool bar. Maybe, I should
  203. try to just add the tool bar when a GPD is displayed...
  204. void CMainFrame::OnViewStatusBar()
  205. {
  206. CMenu* pcm = GetMenu() ;
  207. unsigned ustate = pcm->GetMenuState(ID_VIEW_STATUS_BAR, MF_BYCOMMAND) ;
  208. if (ustate & MF_CHECKED) {
  209. m_wndStatusBar.ShowWindow(SW_HIDE) ;
  210. pcm->CheckMenuItem(ID_VIEW_STATUS_BAR, MF_UNCHECKED) ;
  211. } else {
  212. m_wndStatusBar.ShowWindow(SW_SHOW) ;
  213. pcm->CheckMenuItem(ID_VIEW_STATUS_BAR, MF_CHECKED) ;
  214. } ;
  215. RecalcLayout() ;
  216. }
  217. */