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.

302 lines
6.9 KiB

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