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.

360 lines
7.8 KiB

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