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.

269 lines
6.4 KiB

  1. //
  2. // Driver Verifier UI
  3. // Copyright (c) Microsoft Corporation, 1999
  4. //
  5. //
  6. // module: DrvCSht.cxx
  7. // author: DMihai
  8. // created: 01/04/98
  9. //
  10. // Description:
  11. //
  12. // App's PropertySheet.
  13. //
  14. #include "stdafx.h"
  15. #include "drvvctrl.hxx"
  16. #include "DrvCSht.hxx"
  17. //
  18. // help IDs
  19. //
  20. static DWORD MyHelpIds[] =
  21. {
  22. IDCANCEL, IDH_DV_common_exit,
  23. 0, 0
  24. };
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CDrvChkSheet property sheet
  27. //////////////////////////////////////////////////////////////////////
  28. // Construction/Destruction
  29. //////////////////////////////////////////////////////////////////////
  30. CDrvChkSheet::CDrvChkSheet()
  31. : CPropertySheet(IDS_APPTITLE)
  32. {
  33. //{{AFX_DATA_INIT(CDrvChkSheet)
  34. //}}AFX_DATA_INIT
  35. AddPage( &m_CrtSettPage );
  36. AddPage( &m_CountPage );
  37. AddPage( &m_PoolCountersPage );
  38. AddPage( &m_ModifPage );
  39. AddPage( &m_VolatilePage );
  40. m_psh.dwFlags |= PSH_NOAPPLYNOW;
  41. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  42. }
  43. CDrvChkSheet::~CDrvChkSheet()
  44. {
  45. }
  46. //////////////////////////////////////////////////////////////////////
  47. void CDrvChkSheet::DoDataExchange(CDataExchange* pDX)
  48. {
  49. CPropertySheet::DoDataExchange( pDX );
  50. //{{AFX_DATA_MAP(CDrvChkSheet)
  51. //}}AFX_DATA_MAP
  52. }
  53. BEGIN_MESSAGE_MAP(CDrvChkSheet, CPropertySheet)
  54. //{{AFX_MSG_MAP(CDrvChkSheet)
  55. ON_WM_SYSCOMMAND()
  56. ON_WM_PAINT()
  57. ON_WM_QUERYDRAGICON()
  58. ON_MESSAGE( WM_HELP, OnHelp )
  59. ON_MESSAGE( WM_CONTEXTMENU, OnContextMenu )
  60. //}}AFX_MSG_MAP
  61. END_MESSAGE_MAP()
  62. //////////////////////////////////////////////////////////////////////
  63. void CDrvChkSheet::ModifyButtons()
  64. {
  65. BOOL bHaveHelpButton = FALSE;
  66. CWnd *pWnd;
  67. CString strQuit;
  68. CRect rectHelp;
  69. //
  70. // Hide the OK button
  71. //
  72. pWnd = GetDlgItem( IDOK );
  73. if( pWnd != NULL )
  74. {
  75. ASSERT_VALID( pWnd );
  76. pWnd->ShowWindow( SW_HIDE );
  77. }
  78. //
  79. // Hide the Help button
  80. //
  81. pWnd = GetDlgItem( IDHELP );
  82. if( pWnd != NULL )
  83. {
  84. ASSERT_VALID( pWnd );
  85. pWnd->GetWindowRect( rectHelp );
  86. ScreenToClient( rectHelp );
  87. bHaveHelpButton = TRUE;
  88. pWnd->ShowWindow( SW_HIDE );
  89. }
  90. //
  91. // Cancel button becomes Exit
  92. //
  93. pWnd = GetDlgItem( IDCANCEL );
  94. if( pWnd != NULL )
  95. {
  96. ASSERT_VALID( pWnd );
  97. VERIFY( strQuit.LoadString( IDS_QUIT ) );
  98. pWnd->SetWindowText( strQuit );
  99. if( bHaveHelpButton )
  100. {
  101. pWnd->MoveWindow( rectHelp );
  102. }
  103. }
  104. }
  105. //////////////////////////////////////////////////////////////////////
  106. // message handlers
  107. BOOL CDrvChkSheet::OnInitDialog()
  108. {
  109. BOOL bResult = CPropertySheet::OnInitDialog();
  110. //
  111. // Add the context sensitive button to the titlebar
  112. //
  113. LONG lStyle = ::GetWindowLong(m_hWnd, GWL_EXSTYLE);
  114. lStyle |= WS_EX_CONTEXTHELP;
  115. ::SetWindowLong(m_hWnd, GWL_EXSTYLE, lStyle);
  116. // Add "About..." menu item to system menu.
  117. // IDM_ABOUTBOX must be in the system command range.
  118. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  119. ASSERT(IDM_ABOUTBOX < 0xF000);
  120. CMenu* pSysMenu = GetSystemMenu(FALSE);
  121. if (pSysMenu != NULL)
  122. {
  123. CString strAboutMenu;
  124. strAboutMenu.LoadString(IDS_ABOUTBOX);
  125. if (!strAboutMenu.IsEmpty())
  126. {
  127. pSysMenu->AppendMenu(MF_SEPARATOR);
  128. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  129. }
  130. }
  131. // Set the icon for this dialog. The framework does this automatically
  132. // when the application's main window is not a dialog
  133. SetIcon(m_hIcon, TRUE); // Set big icon
  134. SetIcon(m_hIcon, FALSE); // Set small icon
  135. // TODO: Add extra initialization here
  136. ModifyButtons();
  137. return bResult;
  138. }
  139. //////////////////////////////////////////////////////////////////////
  140. void CDrvChkSheet::OnSysCommand(UINT nID, LPARAM lParam)
  141. {
  142. CString strWndTitle;
  143. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  144. {
  145. GetWindowText( strWndTitle );
  146. ShellAbout( m_hWnd, (LPCTSTR)strWndTitle, NULL, m_hIcon );
  147. }
  148. else
  149. {
  150. CPropertySheet::OnSysCommand(nID, lParam);
  151. }
  152. }
  153. //////////////////////////////////////////////////////////////////////
  154. // If you add a minimize button to your dialog, you will need the code below
  155. // to draw the icon. For MFC applications using the document/view model,
  156. // this is automatically done for you by the framework.
  157. void CDrvChkSheet::OnPaint()
  158. {
  159. if (IsIconic())
  160. {
  161. CPaintDC dc(this); // device context for painting
  162. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  163. // Center icon in client rectangle
  164. int cxIcon = GetSystemMetrics(SM_CXICON);
  165. int cyIcon = GetSystemMetrics(SM_CYICON);
  166. CRect rect;
  167. GetClientRect(&rect);
  168. int x = (rect.Width() - cxIcon + 1) / 2;
  169. int y = (rect.Height() - cyIcon + 1) / 2;
  170. // Draw the icon
  171. dc.DrawIcon(x, y, m_hIcon);
  172. }
  173. else
  174. {
  175. CPropertySheet::OnPaint();
  176. }
  177. }
  178. //////////////////////////////////////////////////////////////////////
  179. // The system calls this to obtain the cursor to display while the user drags
  180. // the minimized window.
  181. HCURSOR CDrvChkSheet::OnQueryDragIcon()
  182. {
  183. return (HCURSOR) m_hIcon;
  184. }
  185. //////////////////////////////////////////////////////////////////////
  186. BOOL CDrvChkSheet::OnQueryCancel()
  187. {
  188. if( GetActivePage() != &m_ModifPage )
  189. {
  190. return m_ModifPage.OnQueryCancel();
  191. }
  192. return TRUE;
  193. }
  194. /////////////////////////////////////////////////////////////
  195. LONG CDrvChkSheet::OnHelp( WPARAM wParam, LPARAM lParam )
  196. {
  197. LONG lResult = 0;
  198. LPHELPINFO lpHelpInfo = (LPHELPINFO)lParam;
  199. ::WinHelp(
  200. (HWND) lpHelpInfo->hItemHandle,
  201. VERIFIER_HELP_FILE,
  202. HELP_WM_HELP,
  203. (DWORD_PTR) MyHelpIds );
  204. return lResult;
  205. }
  206. /////////////////////////////////////////////////////////////
  207. LONG CDrvChkSheet::OnContextMenu( WPARAM wParam, LPARAM lParam )
  208. {
  209. LONG lResult = 0;
  210. ::WinHelp(
  211. (HWND) wParam,
  212. VERIFIER_HELP_FILE,
  213. HELP_CONTEXTMENU,
  214. (DWORD_PTR) MyHelpIds );
  215. return lResult;
  216. }