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.

440 lines
11 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // WelcomePage.cpp
  7. //
  8. // Maintained By:
  9. // Geoffrey Pease (GPease) 12-MAY-2000
  10. //
  11. //////////////////////////////////////////////////////////////////////////////
  12. //////////////////////////////////////////////////////////////////////////////
  13. // Include Files
  14. //////////////////////////////////////////////////////////////////////////////
  15. #include "Pch.h"
  16. #include "WelcomePage.h"
  17. //////////////////////////////////////////////////////////////////////////////
  18. // Constant Definitions
  19. //////////////////////////////////////////////////////////////////////////////
  20. DEFINE_THISCLASS("CWelcomePage");
  21. //*************************************************************************//
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CWelcomePage class
  24. /////////////////////////////////////////////////////////////////////////////
  25. //////////////////////////////////////////////////////////////////////////////
  26. //++
  27. //
  28. // CWelcomePage::CWelcomePage
  29. //
  30. // Description:
  31. // Constructor
  32. //
  33. // Arguments:
  34. // ecamCreateAddModeIn
  35. // Creating cluster or adding nodes to cluster.
  36. //
  37. // Return Values:
  38. // None.
  39. //
  40. //--
  41. //////////////////////////////////////////////////////////////////////////////
  42. CWelcomePage::CWelcomePage(
  43. CClusCfgWizard * pccwIn
  44. , ECreateAddMode ecamCreateAddModeIn
  45. ) : m_pccw( pccwIn )
  46. {
  47. TraceFunc( "" );
  48. //
  49. // Cannot Assert that these are in a zero state since this page
  50. // is allocated on the stack and not by our zero-initing heap alloc
  51. // function...
  52. //
  53. m_hwnd = NULL;
  54. m_hFont = NULL;
  55. Assert( m_pccw != NULL );
  56. m_pccw->AddRef();
  57. m_ecamCreateAddMode = ecamCreateAddModeIn;
  58. TraceFuncExit();
  59. } //*** CWelcomePage::CWelcomePage
  60. //////////////////////////////////////////////////////////////////////////////
  61. //++
  62. //
  63. // CWelcomePage::~CWelcomePage
  64. //
  65. // Description:
  66. // Destructor
  67. //
  68. // Arguments:
  69. // None.
  70. //
  71. // Return Values:
  72. // None.
  73. //
  74. //--
  75. //////////////////////////////////////////////////////////////////////////////
  76. CWelcomePage::~CWelcomePage( void )
  77. {
  78. TraceFunc( "" );
  79. if ( m_pccw != NULL )
  80. {
  81. m_pccw->Release();
  82. } // if:
  83. if ( m_hFont != NULL )
  84. {
  85. DeleteObject( m_hFont );
  86. } // if:
  87. TraceFuncExit();
  88. } //*** CWelcomePage::~CWelcomePage
  89. //////////////////////////////////////////////////////////////////////////////
  90. //++
  91. //
  92. // CWelcomePage::OnInitDialog
  93. //
  94. // Description:
  95. // Process the WM_INIT_DIALOG message.
  96. //
  97. // Arguments:
  98. // None.
  99. //
  100. // Return Values:
  101. // LRESULT TRUE all the time...
  102. //
  103. //--
  104. //////////////////////////////////////////////////////////////////////////////
  105. LRESULT
  106. CWelcomePage::OnInitDialog( void )
  107. {
  108. TraceFunc( "" );
  109. LRESULT lr = TRUE;
  110. HDC hdc = NULL;
  111. HRESULT hr;
  112. NONCLIENTMETRICS ncm;
  113. LOGFONT LogFont;
  114. INT iSize;
  115. DWORD dw;
  116. BOOL fRet;
  117. WCHAR szFontSize[ 3 ]; // shouldn't be bigger than 2 digits!!
  118. BSTR bstrRequirement = NULL;
  119. BSTR bstrFormattedReq = NULL;
  120. BSTR bstrRequirements = NULL;
  121. int idxids;
  122. int cidsRequirements;
  123. UINT * pidsRequirements;
  124. static UINT rgidsCreateRequirements[] =
  125. {
  126. IDS_WELCOME_CREATE_REQ_1
  127. , IDS_WELCOME_CREATE_REQ_2
  128. , IDS_WELCOME_CREATE_REQ_3
  129. , IDS_WELCOME_CREATE_REQ_4
  130. , IDS_WELCOME_CREATE_REQ_5
  131. };
  132. static UINT rgidsAddRequirements[] =
  133. {
  134. IDS_WELCOME_ADD_REQ_1
  135. , IDS_WELCOME_ADD_REQ_2
  136. };
  137. //
  138. // Make the Title static BIG and BOLD. Why the wizard control itself can't
  139. // do this is beyond me!
  140. //
  141. ZeroMemory( &ncm, sizeof( ncm ) );
  142. ZeroMemory( &LogFont, sizeof( LogFont ) );
  143. //
  144. // Find out the system default font metrics.
  145. //
  146. ncm.cbSize = sizeof( ncm );
  147. fRet = SystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
  148. if ( fRet == FALSE )
  149. {
  150. TW32( GetLastError() );
  151. goto Cleanup;
  152. } // if:
  153. //
  154. // Copy it.
  155. //
  156. LogFont = ncm.lfMessageFont;
  157. //
  158. // Make it BOLD.
  159. //
  160. LogFont.lfWeight = FW_BOLD;
  161. //
  162. // Find out what we want it to look like.
  163. //
  164. dw = LoadString( g_hInstance, IDS_LARGEFONTNAME, LogFont.lfFaceName, ARRAYSIZE( LogFont.lfFaceName ) );
  165. AssertMsg( dw != 0, "String missing!" );
  166. dw = LoadString( g_hInstance, IDS_LARGEFONTSIZE, szFontSize, ARRAYSIZE( szFontSize ) );
  167. AssertMsg( dw != 0, "String missing!" );
  168. iSize = wcstoul( szFontSize, NULL, 10 );
  169. //
  170. // Grab the DC.
  171. //
  172. hdc = GetDC( m_hwnd );
  173. if ( hdc == NULL )
  174. {
  175. TW32( GetLastError() );
  176. goto Cleanup;
  177. } // if:
  178. //
  179. // Use the magic equation....
  180. //
  181. LogFont.lfHeight = 0 - ( GetDeviceCaps( hdc, LOGPIXELSY ) * iSize / 72 );
  182. //
  183. // Create the font.
  184. //
  185. m_hFont = CreateFontIndirect( &LogFont );
  186. if ( m_hFont == NULL )
  187. {
  188. TW32( GetLastError() );
  189. goto Cleanup;
  190. } // if:
  191. //
  192. // Apply the font.
  193. //
  194. SetWindowFont( GetDlgItem( m_hwnd, IDC_WELCOME_S_TITLE ), m_hFont, TRUE );
  195. //
  196. // Load the requirement text.
  197. //
  198. if ( m_ecamCreateAddMode == camCREATING )
  199. {
  200. pidsRequirements = rgidsCreateRequirements;
  201. cidsRequirements = ARRAYSIZE( rgidsCreateRequirements );
  202. } // if: creating a new cluster
  203. else
  204. {
  205. pidsRequirements = rgidsAddRequirements;
  206. cidsRequirements = ARRAYSIZE( rgidsAddRequirements );
  207. } // else: adding nodes to an existing cluster
  208. for ( idxids = 0 ; idxids < cidsRequirements ; idxids++ )
  209. {
  210. hr = HrLoadStringIntoBSTR( g_hInstance, pidsRequirements[ idxids ], &bstrRequirement );
  211. if ( FAILED( hr ) )
  212. {
  213. goto Cleanup;
  214. } // if:
  215. hr = HrFormatStringIntoBSTR( L" - %1!ws!\n", &bstrFormattedReq, bstrRequirement );
  216. if ( FAILED( hr ) )
  217. {
  218. goto Cleanup;
  219. } // if:
  220. hr = HrConcatenateBSTRs( &bstrRequirements, bstrFormattedReq );
  221. if ( FAILED( hr ) )
  222. {
  223. goto Cleanup;
  224. } // if:
  225. TraceSysFreeString( bstrRequirement );
  226. bstrRequirement = NULL;
  227. } // for: each requirement string
  228. SetDlgItemText( m_hwnd, IDC_WELCOME_S_REQUIREMENTS, bstrRequirements );
  229. Cleanup:
  230. if ( hdc != NULL )
  231. {
  232. ReleaseDC( m_hwnd, hdc );
  233. } // if:
  234. TraceSysFreeString( bstrRequirement );
  235. TraceSysFreeString( bstrFormattedReq );
  236. TraceSysFreeString( bstrRequirements );
  237. RETURN( lr );
  238. } //*** CWelcomePage::OnInitDialog
  239. //////////////////////////////////////////////////////////////////////////////
  240. //++
  241. //
  242. // CWelcomePage::OnNotifyWizNext
  243. //
  244. // Description:
  245. // Process the PSN_WIZNEXT notification message.
  246. //
  247. // Arguments:
  248. // None.
  249. //
  250. // Return Values:
  251. // LRESULT TRUE all the time...
  252. //
  253. //--
  254. //////////////////////////////////////////////////////////////////////////////
  255. LRESULT
  256. CWelcomePage::OnNotifyWizNext( void )
  257. {
  258. TraceFunc( "" );
  259. Assert( m_pccw != NULL );
  260. RETURN( (LRESULT) TRUE );
  261. } //*** CWelcomePage::OnNotifyWizNext
  262. //////////////////////////////////////////////////////////////////////////////
  263. //++
  264. //
  265. // CWelcomePage::OnNotify
  266. //
  267. // Description:
  268. // Process the WM_NOTIFY message.
  269. //
  270. // Arguments:
  271. // idCtrlIn
  272. //
  273. // pnmhdrIn
  274. //
  275. // Return Values:
  276. // LRESULT TRUE or FALSE
  277. //
  278. //--
  279. //////////////////////////////////////////////////////////////////////////////
  280. LRESULT
  281. CWelcomePage::OnNotify(
  282. WPARAM idCtrlIn
  283. , LPNMHDR pnmhdrIn
  284. )
  285. {
  286. TraceFunc( "" );
  287. LRESULT lr = TRUE;
  288. SetWindowLongPtr( m_hwnd, DWLP_MSGRESULT, 0 );
  289. switch( pnmhdrIn->code )
  290. {
  291. case PSN_SETACTIVE:
  292. PropSheet_SetWizButtons( GetParent( m_hwnd ), PSWIZB_NEXT );
  293. break;
  294. case PSN_WIZNEXT:
  295. lr = OnNotifyWizNext();
  296. break;
  297. } // switch:
  298. RETURN( lr );
  299. } //*** CWelcomePage::OnNotify
  300. //////////////////////////////////////////////////////////////////////////////
  301. //++
  302. //
  303. // CWelcomePage::OnInitDialog
  304. //
  305. // Description:
  306. // Dialog proc for the Welcome page in the Wizard.
  307. //
  308. // Arguments:
  309. // hwndDlgIn
  310. // Window handle to this page.
  311. //
  312. // nMsgIn
  313. // The windows message that was sent to this page.
  314. //
  315. // wParam
  316. // The WPARAM of the message above. This is different for
  317. // different messages.
  318. //
  319. // lParam
  320. // The LPARAM of the message above. This is different for
  321. // different messages.
  322. //
  323. // Return Values:
  324. // LRESULT
  325. //
  326. //--
  327. //////////////////////////////////////////////////////////////////////////////
  328. INT_PTR CALLBACK
  329. CWelcomePage::S_DlgProc(
  330. HWND hwndDlgIn
  331. , UINT nMsgIn
  332. , WPARAM wParam
  333. , LPARAM lParam
  334. )
  335. {
  336. // Don't do TraceFunc because every mouse movement
  337. // will cause this function to be called.
  338. WndMsg( hwndDlgIn, nMsgIn, wParam, lParam );
  339. LRESULT lr = FALSE;
  340. CWelcomePage * pPage;
  341. if ( nMsgIn == WM_INITDIALOG )
  342. {
  343. PROPSHEETPAGE * ppage = reinterpret_cast< PROPSHEETPAGE * >( lParam );
  344. SetWindowLongPtr( hwndDlgIn, GWLP_USERDATA, (LPARAM) ppage->lParam );
  345. pPage = reinterpret_cast< CWelcomePage * >( ppage->lParam );
  346. pPage->m_hwnd = hwndDlgIn;
  347. } // if:
  348. else
  349. {
  350. pPage = reinterpret_cast< CWelcomePage *> ( GetWindowLongPtr( hwndDlgIn, GWLP_USERDATA ) );
  351. } // else:
  352. if ( pPage != NULL )
  353. {
  354. Assert( hwndDlgIn == pPage->m_hwnd );
  355. switch ( nMsgIn )
  356. {
  357. case WM_INITDIALOG:
  358. lr = pPage->OnInitDialog();
  359. break;
  360. case WM_NOTIFY:
  361. lr = pPage->OnNotify( wParam, reinterpret_cast< LPNMHDR >( lParam ) );
  362. break;
  363. // no default clause needed
  364. } // switch: nMsgIn
  365. } // if: page is specified
  366. return lr;
  367. } //*** CWelcomePage::S_DlgProc