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.

341 lines
7.6 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // WelcomePage.cpp
  7. //
  8. // Maintained By:
  9. // Geoffrey Pease (GPease) 12-MAY-2000
  10. //
  11. //////////////////////////////////////////////////////////////////////////////
  12. #include "Pch.h"
  13. #include "WelcomePage.h"
  14. DEFINE_THISCLASS("CWelcomePage");
  15. //////////////////////////////////////////////////////////////////////////////
  16. //++
  17. //
  18. // CWelcomePage::CWelcomePage
  19. //
  20. // Description:
  21. // Constructor.
  22. //
  23. // Arguments:
  24. // ecamCreateAddModeIn -- Creating cluster or adding nodes to cluster.
  25. //
  26. // Return Values:
  27. // None.
  28. //
  29. //--
  30. //////////////////////////////////////////////////////////////////////////////
  31. CWelcomePage::CWelcomePage(
  32. ECreateAddMode ecamCreateAddModeIn
  33. )
  34. {
  35. TraceFunc( "" );
  36. // m_hwnd
  37. m_hFont = NULL;
  38. m_ecamCreateAddMode = ecamCreateAddModeIn;
  39. TraceFuncExit();
  40. } //*** CWelcomePage::CWelcomePage()
  41. //////////////////////////////////////////////////////////////////////////////
  42. //++
  43. //
  44. // CWelcomePage::~CWelcomePage( void )
  45. //
  46. //--
  47. //////////////////////////////////////////////////////////////////////////////
  48. CWelcomePage::~CWelcomePage( void )
  49. {
  50. TraceFunc( "" );
  51. if ( m_hFont != NULL )
  52. {
  53. DeleteObject( m_hFont );
  54. }
  55. TraceFuncExit();
  56. } //*** CWelcomePage::~CWelcomePage()
  57. //////////////////////////////////////////////////////////////////////////////
  58. //++
  59. //
  60. // LRESULT
  61. // CWelcomePage::OnInitDialog( void )
  62. //
  63. //--
  64. //////////////////////////////////////////////////////////////////////////////
  65. LRESULT
  66. CWelcomePage::OnInitDialog( void )
  67. {
  68. TraceFunc( "" );
  69. LRESULT lr = TRUE;
  70. HDC hdc = NULL;
  71. HRESULT hr;
  72. NONCLIENTMETRICS ncm;
  73. LOGFONT LogFont;
  74. INT iSize;
  75. DWORD dw;
  76. BOOL fRet;
  77. WCHAR szFontSize[ 3 ]; // shouldn't be bigger than 2 digits!!
  78. BSTR bstrRequirement = NULL;
  79. BSTR bstrFormattedReq = NULL;
  80. BSTR bstrRequirements = NULL;
  81. int idxids;
  82. int cidsRequirements;
  83. UINT * pidsRequirements;
  84. static UINT rgidsCreateRequirements[] =
  85. {
  86. IDS_WELCOME_CREATE_REQ_1
  87. , IDS_WELCOME_CREATE_REQ_2
  88. , IDS_WELCOME_CREATE_REQ_3
  89. , IDS_WELCOME_CREATE_REQ_4
  90. , IDS_WELCOME_CREATE_REQ_5
  91. };
  92. static UINT rgidsAddRequirements[] =
  93. {
  94. IDS_WELCOME_ADD_REQ_1
  95. , IDS_WELCOME_ADD_REQ_2
  96. };
  97. //
  98. // Make the Title static BIG and BOLD. Why the wizard control itself can't
  99. // do this is beyond me!
  100. //
  101. ZeroMemory( &ncm, sizeof( ncm ) );
  102. ZeroMemory( &LogFont, sizeof( LOGFONT ) );
  103. //
  104. // Find out the system default font metrics.
  105. //
  106. ncm.cbSize = sizeof( ncm );
  107. fRet = SystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
  108. if ( ! fRet )
  109. {
  110. goto Win32Error;
  111. }
  112. //
  113. // Copy it.
  114. //
  115. LogFont = ncm.lfMessageFont;
  116. //
  117. // Make it BOLD.
  118. //
  119. LogFont.lfWeight = FW_BOLD;
  120. //
  121. // Find out what we want it to look like.
  122. //
  123. dw = LoadString( g_hInstance, IDS_LARGEFONTNAME, LogFont.lfFaceName, ARRAYSIZE( LogFont.lfFaceName ) );
  124. AssertMsg( dw != 0, "String missing!" );
  125. dw = LoadString( g_hInstance, IDS_LARGEFONTSIZE, szFontSize, ARRAYSIZE( szFontSize ) );
  126. AssertMsg( dw != 0, "String missing!" );
  127. iSize = wcstoul( szFontSize, NULL, 10 );
  128. //
  129. // Grab the DC.
  130. //
  131. hdc = GetDC( m_hwnd );
  132. if ( hdc == NULL )
  133. {
  134. goto Win32Error;
  135. }
  136. //
  137. // Use the magic equation....
  138. //
  139. LogFont.lfHeight = 0 - ( GetDeviceCaps( hdc, LOGPIXELSY ) * iSize / 72 );
  140. //
  141. // Create the font.
  142. //
  143. m_hFont = CreateFontIndirect( &LogFont );
  144. if ( m_hFont == NULL )
  145. {
  146. goto Win32Error;
  147. }
  148. //
  149. // Apply the font.
  150. //
  151. SetWindowFont( GetDlgItem( m_hwnd, IDC_WELCOME_S_TITLE ), m_hFont, TRUE );
  152. //
  153. // Load the requirement text.
  154. //
  155. if ( m_ecamCreateAddMode == camCREATING )
  156. {
  157. pidsRequirements = rgidsCreateRequirements;
  158. cidsRequirements = ARRAYSIZE( rgidsCreateRequirements );
  159. } // if: creating a new cluster
  160. else
  161. {
  162. pidsRequirements = rgidsAddRequirements;
  163. cidsRequirements = ARRAYSIZE( rgidsAddRequirements );
  164. } // else: adding nodes to an existing cluster
  165. for ( idxids = 0 ; idxids < cidsRequirements ; idxids++ )
  166. {
  167. hr = HrLoadStringIntoBSTR( g_hInstance, pidsRequirements[ idxids ], &bstrRequirement );
  168. if ( FAILED( hr ) )
  169. {
  170. goto Cleanup;
  171. }
  172. hr = HrFormatStringIntoBSTR( L" - %1!ws!\n", &bstrFormattedReq, bstrRequirement );
  173. if ( FAILED( hr ) )
  174. {
  175. goto Cleanup;
  176. }
  177. hr = HrConcatenateBSTRs( &bstrRequirements, bstrFormattedReq );
  178. if ( FAILED( hr ) )
  179. {
  180. goto Cleanup;
  181. }
  182. TraceSysFreeString( bstrRequirement );
  183. bstrRequirement = NULL;
  184. } // for: each requirement string
  185. SetDlgItemText( m_hwnd, IDC_WELCOME_S_REQUIREMENTS, bstrRequirements );
  186. goto Cleanup;
  187. Win32Error:
  188. TW32( GetLastError() );
  189. Cleanup:
  190. if ( hdc != NULL )
  191. {
  192. ReleaseDC( m_hwnd, hdc );
  193. }
  194. TraceSysFreeString( bstrRequirement );
  195. TraceSysFreeString( bstrFormattedReq );
  196. TraceSysFreeString( bstrRequirements );
  197. RETURN( lr );
  198. } //*** CWelcomePage::OnInitDialog()
  199. //////////////////////////////////////////////////////////////////////////////
  200. //++
  201. //
  202. // LRESULT
  203. // CWelcomePage::OnNotify(
  204. // WPARAM idCtrlIn,
  205. // LPNMHDR pnmhdrIn
  206. // )
  207. //
  208. //--
  209. //////////////////////////////////////////////////////////////////////////////
  210. LRESULT
  211. CWelcomePage::OnNotify(
  212. WPARAM idCtrlIn,
  213. LPNMHDR pnmhdrIn
  214. )
  215. {
  216. TraceFunc( "" );
  217. LRESULT lr = TRUE;
  218. SetWindowLongPtr( m_hwnd, DWLP_MSGRESULT, 0 );
  219. switch( pnmhdrIn->code )
  220. {
  221. case PSN_SETACTIVE:
  222. PropSheet_SetWizButtons( GetParent( m_hwnd ), PSWIZB_NEXT );
  223. break;
  224. }
  225. RETURN( lr );
  226. } //*** CWelcomePage::OnNotify()
  227. //////////////////////////////////////////////////////////////////////////////
  228. //++
  229. //
  230. // INT_PTR
  231. // CALLBACK
  232. // CWelcomePage::S_DlgProc(
  233. // HWND hwhndDlgIn,
  234. // UINT nMsgIn,
  235. // WPARAM wParam,
  236. // LPARAM lParam
  237. // )
  238. //
  239. //--
  240. //////////////////////////////////////////////////////////////////////////////
  241. INT_PTR
  242. CALLBACK
  243. CWelcomePage::S_DlgProc(
  244. HWND hwndDlgIn,
  245. UINT nMsgIn,
  246. WPARAM wParam,
  247. LPARAM lParam
  248. )
  249. {
  250. // Don't do TraceFunc because every mouse movement
  251. // will cause this function to be called.
  252. WndMsg( hwndDlgIn, nMsgIn, wParam, lParam );
  253. LRESULT lr = FALSE;
  254. CWelcomePage * pPage;
  255. if ( nMsgIn == WM_INITDIALOG )
  256. {
  257. PROPSHEETPAGE * ppage = reinterpret_cast< PROPSHEETPAGE * >( lParam );
  258. SetWindowLongPtr( hwndDlgIn, GWLP_USERDATA, (LPARAM) ppage->lParam );
  259. pPage = reinterpret_cast< CWelcomePage * >( ppage->lParam );
  260. pPage->m_hwnd = hwndDlgIn;
  261. }
  262. else
  263. {
  264. pPage = reinterpret_cast< CWelcomePage *> ( GetWindowLongPtr( hwndDlgIn, GWLP_USERDATA ) );
  265. }
  266. if ( pPage != NULL )
  267. {
  268. Assert( hwndDlgIn == pPage->m_hwnd );
  269. switch ( nMsgIn )
  270. {
  271. case WM_INITDIALOG:
  272. lr = pPage->OnInitDialog();
  273. break;
  274. case WM_NOTIFY:
  275. lr = pPage->OnNotify( wParam, reinterpret_cast< LPNMHDR >( lParam ) );
  276. break;
  277. // no default clause needed
  278. } // switch: nMsgIn
  279. } // if: page is specified
  280. return lr;
  281. } //*** CWelcomePage::S_DlgProc()