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.

336 lines
8.0 KiB

  1. //
  2. // Driver Verifier UI
  3. // Copyright (c) Microsoft Corporation, 1999
  4. //
  5. //
  6. //
  7. // module: VSheet.cpp
  8. // author: DMihai
  9. // created: 11/1/00
  10. //
  11. // Description:
  12. //
  13. #include "stdafx.h"
  14. #include "verifier.h"
  15. #include "vsheet.h"
  16. #include "taspage.h"
  17. #include "vglobal.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CVerifierPropSheet dialog
  25. CVerifierPropSheet::CVerifierPropSheet()
  26. : CPropertySheet(IDS_APPTITLE)
  27. {
  28. //{{AFX_DATA_INIT(CVerifierPropSheet)
  29. // NOTE: the ClassWizard will add member initialization here
  30. //}}AFX_DATA_INIT
  31. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  32. m_TypAdvStatPage.SetParentSheet( this );
  33. m_DriverSetPage.SetParentSheet( this );
  34. m_CustSettPage.SetParentSheet( this );
  35. m_ConfDriversListPage.SetParentSheet( this );
  36. m_SelectDriversPage.SetParentSheet( this );
  37. m_FullListSettingsPage.SetParentSheet( this );
  38. m_DriverStatusPage.SetParentSheet( this );
  39. m_CrtRegSettingsPage.SetParentSheet( this );
  40. m_GlobalCountPage.SetParentSheet( this );
  41. m_DriverCountersPage.SetParentSheet( this );
  42. m_DiskListPage.SetParentSheet( this );
  43. m_TypAdvStatPage.m_psp.dwFlags &= ~PSH_HASHELP;
  44. m_DriverSetPage.m_psp.dwFlags &= ~PSH_HASHELP;
  45. m_CustSettPage.m_psp.dwFlags &= ~PSH_HASHELP;
  46. m_ConfDriversListPage.m_psp.dwFlags &= ~PSH_HASHELP;
  47. m_SelectDriversPage.m_psp.dwFlags &= ~PSH_HASHELP;
  48. m_FullListSettingsPage.m_psp.dwFlags &= ~PSH_HASHELP;
  49. m_DriverStatusPage.m_psp.dwFlags &= ~PSH_HASHELP;
  50. m_CrtRegSettingsPage.m_psp.dwFlags &= ~PSH_HASHELP;
  51. m_GlobalCountPage.m_psp.dwFlags &= ~PSH_HASHELP;
  52. m_DriverCountersPage.m_psp.dwFlags &= ~PSH_HASHELP;
  53. m_DiskListPage.m_psp.dwFlags &= ~PSH_HASHELP;
  54. m_psh.dwFlags &= ~PSH_HASHELP;
  55. m_psh.dwFlags |= PSH_WIZARDCONTEXTHELP;
  56. AddPage( &m_TypAdvStatPage );
  57. AddPage( &m_DriverSetPage );
  58. AddPage( &m_CustSettPage );
  59. AddPage( &m_ConfDriversListPage );
  60. AddPage( &m_SelectDriversPage );
  61. AddPage( &m_FullListSettingsPage );
  62. AddPage( &m_CrtRegSettingsPage );
  63. AddPage( &m_DriverStatusPage );
  64. AddPage( &m_GlobalCountPage );
  65. AddPage( &m_DriverCountersPage );
  66. AddPage( &m_DiskListPage );
  67. SetWizardMode();
  68. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  69. }
  70. void CVerifierPropSheet::DoDataExchange(CDataExchange* pDX)
  71. {
  72. CPropertySheet::DoDataExchange(pDX);
  73. //{{AFX_DATA_MAP(CVerifierPropSheet)
  74. // NOTE: the ClassWizard will add DDX and DDV calls here
  75. //}}AFX_DATA_MAP
  76. }
  77. BEGIN_MESSAGE_MAP(CVerifierPropSheet, CPropertySheet)
  78. //{{AFX_MSG_MAP(CVerifierPropSheet)
  79. ON_WM_SYSCOMMAND()
  80. ON_WM_PAINT()
  81. ON_WM_QUERYDRAGICON()
  82. ON_WM_HELPINFO()
  83. //}}AFX_MSG_MAP
  84. END_MESSAGE_MAP()
  85. /////////////////////////////////////////////////////////////////////////////
  86. BOOL CVerifierPropSheet::SetContextStrings( ULONG uTitleResId )
  87. {
  88. return m_ConfDriversListPage.SetContextStrings( uTitleResId );
  89. }
  90. /////////////////////////////////////////////////////////////////////////////
  91. VOID CVerifierPropSheet::HideHelpButton()
  92. {
  93. INT xDelta;
  94. CRect rect1;
  95. CRect rect2;
  96. CWnd *pButton;
  97. //
  98. // Help button
  99. //
  100. pButton = GetDlgItem( IDHELP );
  101. if( NULL == pButton )
  102. {
  103. //
  104. // No help button?!?
  105. //
  106. goto Done;
  107. }
  108. pButton->ShowWindow( SW_HIDE );
  109. pButton->GetWindowRect( &rect1 );
  110. ScreenToClient( &rect1 );
  111. //
  112. // Cancel button
  113. //
  114. pButton = GetDlgItem( IDCANCEL );
  115. if( NULL == pButton )
  116. {
  117. //
  118. // No Cancel button?!?
  119. //
  120. goto Done;
  121. }
  122. pButton->GetWindowRect( &rect2 );
  123. ScreenToClient( &rect2 );
  124. xDelta = rect1.left - rect2.left;
  125. rect2.OffsetRect( xDelta, 0 );
  126. pButton->MoveWindow( rect2 );
  127. //
  128. // Back button
  129. //
  130. pButton = GetDlgItem( ID_WIZBACK );
  131. if( NULL != pButton )
  132. {
  133. pButton->GetWindowRect( &rect2 );
  134. ScreenToClient( &rect2 );
  135. rect2.OffsetRect( xDelta, 0 );
  136. pButton->MoveWindow( rect2 );
  137. }
  138. //
  139. // Next button
  140. //
  141. pButton = GetDlgItem( ID_WIZNEXT );
  142. if( NULL != pButton )
  143. {
  144. pButton->GetWindowRect( &rect2 );
  145. ScreenToClient( &rect2 );
  146. rect2.OffsetRect( xDelta, 0 );
  147. pButton->MoveWindow( rect2 );
  148. }
  149. //
  150. // Finish button
  151. //
  152. pButton = GetDlgItem( ID_WIZFINISH );
  153. if( NULL != pButton )
  154. {
  155. pButton->GetWindowRect( &rect2 );
  156. ScreenToClient( &rect2 );
  157. rect2.OffsetRect( xDelta, 0 );
  158. pButton->MoveWindow( rect2 );
  159. }
  160. Done:
  161. NOTHING;
  162. }
  163. /////////////////////////////////////////////////////////////////////////////
  164. // CVerifierPropSheet message handlers
  165. BOOL CVerifierPropSheet::OnInitDialog()
  166. {
  167. CPropertySheet::OnInitDialog();
  168. //
  169. // Add "About..." menu item to system menu.
  170. //
  171. //
  172. // IDM_ABOUTBOX must be in the system command range.
  173. //
  174. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  175. ASSERT(IDM_ABOUTBOX < 0xF000);
  176. CMenu* pSysMenu = GetSystemMenu(FALSE);
  177. if (pSysMenu != NULL)
  178. {
  179. CString strAboutMenu;
  180. strAboutMenu.LoadString(IDS_ABOUTBOX);
  181. if (!strAboutMenu.IsEmpty())
  182. {
  183. pSysMenu->AppendMenu(MF_SEPARATOR);
  184. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  185. }
  186. }
  187. //
  188. // Set the icon for this dialog. The framework does this automatically
  189. // when the application's main window is not a dialog.
  190. //
  191. SetIcon(m_hIcon, TRUE); // Set big icon
  192. SetIcon(m_hIcon, FALSE); // Set small icon
  193. //
  194. // Hide the big Help button - NT keeps creating it even if we
  195. // have specified ~PSH_HASHELP
  196. //
  197. HideHelpButton();
  198. //
  199. // Add the context sensitive button to the titlebar
  200. //
  201. LONG lStyle = ::GetWindowLong(m_hWnd, GWL_EXSTYLE);
  202. lStyle |= WS_EX_CONTEXTHELP;
  203. ::SetWindowLong(m_hWnd, GWL_EXSTYLE, lStyle);
  204. return TRUE; // return TRUE unless you set the focus to a control
  205. }
  206. /////////////////////////////////////////////////////////////////////////////
  207. void CVerifierPropSheet::OnSysCommand(UINT nID, LPARAM lParam)
  208. {
  209. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  210. {
  211. ShellAbout( m_hWnd,
  212. (LPCTSTR)g_strAppName,
  213. NULL,
  214. m_hIcon );
  215. }
  216. else
  217. {
  218. CPropertySheet::OnSysCommand( nID,
  219. lParam);
  220. }
  221. }
  222. /////////////////////////////////////////////////////////////////////////////
  223. //
  224. // If you add a minimize button to your dialog, you will need the code below
  225. // to draw the icon. For MFC applications using the document/view model,
  226. // this is automatically done for you by the framework.
  227. //
  228. void CVerifierPropSheet::OnPaint()
  229. {
  230. if (IsIconic())
  231. {
  232. //
  233. // Device context for painting
  234. //
  235. CPaintDC dc(this);
  236. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  237. //
  238. // Center icon in client rectangle
  239. //
  240. int cxIcon = GetSystemMetrics(SM_CXICON);
  241. int cyIcon = GetSystemMetrics(SM_CYICON);
  242. CRect rect;
  243. GetClientRect(&rect);
  244. int x = (rect.Width() - cxIcon + 1) / 2;
  245. int y = (rect.Height() - cyIcon + 1) / 2;
  246. //
  247. // Draw the icon
  248. //
  249. dc.DrawIcon(x, y, m_hIcon);
  250. }
  251. else
  252. {
  253. CPropertySheet::OnPaint();
  254. }
  255. }
  256. /////////////////////////////////////////////////////////////////////////////
  257. //
  258. // The system calls this to obtain the cursor to display while the user drags
  259. // the minimized window.
  260. //
  261. HCURSOR CVerifierPropSheet::OnQueryDragIcon()
  262. {
  263. return (HCURSOR) m_hIcon;
  264. }
  265. /////////////////////////////////////////////////////////////////////////////
  266. BOOL CVerifierPropSheet::OnHelpInfo(HELPINFO* pHelpInfo)
  267. {
  268. return TRUE;
  269. }
  270. /////////////////////////////////////////////////////////////