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.

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