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.

233 lines
5.7 KiB

  1. //
  2. // Application Verifier UI
  3. // Copyright (c) Microsoft Corporation, 2001
  4. //
  5. //
  6. //
  7. // module: ChooseExe.cpp
  8. // author: CLupu
  9. // created: 04/13/2001
  10. //
  11. // Description:
  12. //
  13. // "Select individual tests" wizard page class.
  14. //
  15. #include "stdafx.h"
  16. #include "appverif.h"
  17. #include "ChooseExe.h"
  18. #include "AVUtil.h"
  19. #include "AVGlobal.h"
  20. #include "Setting.h"
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. TCHAR g_szAppFullPath[MAX_PATH];
  27. TCHAR g_szAppShortName[MAX_PATH];
  28. BOOL g_bStandardSettings;
  29. //
  30. // Help IDs
  31. //
  32. static DWORD MyHelpIds[] =
  33. {
  34. 0, 0
  35. };
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CChooseExePage property page
  38. IMPLEMENT_DYNCREATE(CChooseExePage, CAppverifPage)
  39. CChooseExePage::CChooseExePage() : CAppverifPage(CChooseExePage::IDD)
  40. {
  41. //{{AFX_DATA_INIT(CChooseExePage)
  42. // NOTE: the ClassWizard will add member initialization here
  43. //}}AFX_DATA_INIT
  44. m_nIndSettings = 0;
  45. }
  46. CChooseExePage::~CChooseExePage()
  47. {
  48. }
  49. void CChooseExePage::DoDataExchange(CDataExchange* pDX)
  50. {
  51. CAppverifPage::DoDataExchange(pDX);
  52. //{{AFX_DATA_MAP(CChooseExePage)
  53. DDX_Control(pDX, IDC_EXE_NAME, m_ExeName);
  54. DDX_Radio(pDX, IDC_STANDARD_SETTINGS, m_nIndSettings);
  55. DDX_Control(pDX, IDC_CHOOSEEXE_NEXTDESCR_STATIC, m_NextDescription);
  56. //}}AFX_DATA_MAP
  57. }
  58. BEGIN_MESSAGE_MAP(CChooseExePage, CAppverifPage)
  59. //{{AFX_MSG_MAP(CChooseExePage)
  60. ON_MESSAGE( WM_HELP, OnHelp )
  61. ON_WM_CONTEXTMENU()
  62. ON_BN_CLICKED(IDC_BROWSE, OnChooseExe)
  63. ON_EN_CHANGE(IDC_EXE_NAME, OnChangeExeName)
  64. ON_BN_CLICKED(IDC_STANDARD_SETTINGS, OnUpdateNextDescription)
  65. ON_BN_CLICKED(IDC_ADVANCED_SETTINGS, OnUpdateNextDescription)
  66. //}}AFX_MSG_MAP
  67. END_MESSAGE_MAP()
  68. /////////////////////////////////////////////////////////////////////////////
  69. ULONG CChooseExePage::GetDialogId() const
  70. {
  71. return IDD_CHOOSEEXE_PAGE;
  72. }
  73. /////////////////////////////////////////////////////////////////////////////
  74. void CChooseExePage::OnChooseExe()
  75. {
  76. TCHAR szFilter[] = _T("Executable files (*.exe)\0*.exe\0");
  77. OPENFILENAME ofn;
  78. g_szAppFullPath[0] = 0;
  79. ofn.lStructSize = sizeof(OPENFILENAME);
  80. ofn.hwndOwner = m_hWndTop;
  81. ofn.hInstance = NULL;
  82. ofn.lpstrFilter = szFilter;
  83. ofn.lpstrCustomFilter = NULL;
  84. ofn.nMaxCustFilter = 0;
  85. ofn.nFilterIndex = 0;
  86. ofn.lpstrFile = g_szAppFullPath;
  87. ofn.nMaxFile = MAX_PATH;
  88. ofn.lpstrFileTitle = g_szAppShortName;
  89. ofn.nMaxFileTitle = MAX_PATH;
  90. ofn.lpstrInitialDir = NULL;
  91. ofn.lpstrTitle = _T("Choose a program to run");
  92. ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
  93. ofn.lpstrDefExt = _T("EXE");
  94. if ( !GetOpenFileName(&ofn) )
  95. {
  96. return;
  97. }
  98. m_ExeName.SetWindowText(g_szAppFullPath);
  99. }
  100. void CChooseExePage::OnChangeExeName()
  101. {
  102. if ( m_ExeName.GetWindowTextLength() == 0 )
  103. {
  104. m_pParentSheet->SetWizardButtons( PSWIZB_BACK );
  105. }
  106. else
  107. {
  108. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  109. }
  110. }
  111. /////////////////////////////////////////////////////////////////////////////
  112. // CChooseExePage message handlers
  113. /////////////////////////////////////////////////////////////
  114. LONG CChooseExePage::OnHelp( WPARAM wParam, LPARAM lParam )
  115. {
  116. LONG lResult = 0;
  117. LPHELPINFO lpHelpInfo = (LPHELPINFO)lParam;
  118. ::WinHelp(
  119. (HWND) lpHelpInfo->hItemHandle,
  120. g_szAVHelpFile,
  121. HELP_WM_HELP,
  122. (DWORD_PTR) MyHelpIds );
  123. return lResult;
  124. }
  125. /////////////////////////////////////////////////////////////////////////////
  126. void CChooseExePage::OnContextMenu(CWnd* pWnd, CPoint point)
  127. {
  128. ::WinHelp(
  129. pWnd->m_hWnd,
  130. g_szAVHelpFile,
  131. HELP_CONTEXTMENU,
  132. (DWORD_PTR) MyHelpIds );
  133. }
  134. /////////////////////////////////////////////////////////////////////////////
  135. LRESULT CChooseExePage::OnWizardNext()
  136. {
  137. UpdateData(TRUE);
  138. LRESULT lNextPage = ( m_nIndSettings == 0 ? IDD_STARTAPP_PAGE : IDD_OPTIONS_PAGE );
  139. g_bStandardSettings = (m_nIndSettings == 0);
  140. if ( g_bStandardSettings )
  141. {
  142. g_dwRegFlags = AV_ALL_STANDARD_VERIFIER_FLAGS;
  143. }
  144. GoingToNextPageNotify( lNextPage );
  145. m_ExeName.GetWindowText( g_szAppFullPath, MAX_PATH );
  146. return lNextPage;
  147. }
  148. /////////////////////////////////////////////////////////////////////////////
  149. BOOL CChooseExePage::OnSetActive()
  150. {
  151. ASSERT_VALID( m_pParentSheet );
  152. if ( m_ExeName.GetWindowTextLength() == 0 )
  153. {
  154. m_pParentSheet->SetWizardButtons( PSWIZB_BACK );
  155. }
  156. else
  157. {
  158. m_pParentSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
  159. }
  160. return CAppverifPage::OnSetActive();
  161. }
  162. /////////////////////////////////////////////////////////////////////////////
  163. void CChooseExePage::OnUpdateNextDescription()
  164. {
  165. UpdateData(TRUE);
  166. if ( m_nIndSettings == 0 )
  167. {
  168. AVSetWindowText( m_NextDescription, IDS_CHOOSEEXE_NEXTDESCR_RUNEXE_STATIC );
  169. }
  170. else
  171. {
  172. AVSetWindowText( m_NextDescription, IDS_CHOOSEEXE_NEXTDESCR_OPTIONS_STATIC );
  173. }
  174. }
  175. /////////////////////////////////////////////////////////////////////////////
  176. BOOL CChooseExePage::OnInitDialog()
  177. {
  178. CAppverifPage::OnInitDialog();
  179. AVSetWindowText( m_NextDescription, IDS_CHOOSEEXE_NEXTDESCR_RUNEXE_STATIC );
  180. return TRUE; // return TRUE unless you set the focus to a control
  181. // EXCEPTION: OCX Property Pages should return FALSE
  182. }
  183. /////////////////////////////////////////////////////////////////////////////
  184. // CChooseExePage message handlers