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.

220 lines
5.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1998
  6. //
  7. // File: hdwwiz.c
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "hdwwiz.h"
  11. #include <htmlhelp.h>
  12. BOOL
  13. InitHdwIntroDlgProc(
  14. HWND hDlg,
  15. PHARDWAREWIZ HardwareWiz
  16. )
  17. {
  18. HWND hwnd;
  19. HDC hDC;
  20. HFONT hfont;
  21. HICON hIcon;
  22. LOGFONT LogFont, LogFontOriginal;
  23. int FontSize, PtsPixels;
  24. //
  25. // Set the windows icons, so that we have the correct icon
  26. // in the alt-tab menu.
  27. //
  28. hwnd = GetParent(hDlg);
  29. hIcon = LoadIcon(hHdwWiz,MAKEINTRESOURCE(IDI_HDWWIZICON));
  30. if (hIcon) {
  31. SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
  32. SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
  33. }
  34. hIcon = LoadImage(hHdwWiz,
  35. MAKEINTRESOURCE(IDI_WARN),
  36. IMAGE_ICON,
  37. GetSystemMetrics(SM_CXSMICON),
  38. GetSystemMetrics(SM_CYSMICON),
  39. 0
  40. );
  41. if (hIcon) {
  42. hIcon = (HICON)SendDlgItemMessage(hDlg, IDC_WARNING_ICON, STM_SETICON, (WPARAM)hIcon, 0L);
  43. }
  44. if (hIcon) {
  45. DestroyIcon(hIcon);
  46. }
  47. hfont = (HFONT)SendMessage(GetDlgItem(hDlg, IDC_HDWNAME), WM_GETFONT, 0, 0);
  48. GetObject(hfont, sizeof(LogFont), &LogFont);
  49. LogFontOriginal = LogFont;
  50. HardwareWiz->cyText = LogFont.lfHeight;
  51. if (HardwareWiz->cyText < 0) {
  52. HardwareWiz->cyText = -HardwareWiz->cyText;
  53. }
  54. LogFont = LogFontOriginal;
  55. LogFont.lfWeight = FW_BOLD;
  56. HardwareWiz->hfontTextBold = CreateFontIndirect(&LogFont);
  57. LogFont = LogFontOriginal;
  58. LogFont.lfWeight = FW_BOLD;
  59. hDC = GetDC(hDlg);
  60. if (hDC) {
  61. //
  62. // Bump up font height.
  63. //
  64. PtsPixels = GetDeviceCaps(hDC, LOGPIXELSY);
  65. FontSize = 12;
  66. LogFont.lfHeight = 0 - (PtsPixels * FontSize / 72);
  67. HardwareWiz->hfontTextBigBold = CreateFontIndirect(&LogFont);
  68. }
  69. //
  70. // Create the Marlett font. In the Marlett font the "i" is a bullet.
  71. //
  72. hfont = (HFONT)SendMessage(GetDlgItem(hDlg, IDC_BULLET_1), WM_GETFONT, 0, 0);
  73. GetObject(hfont, sizeof(LogFont), &LogFont);
  74. LogFont.lfCharSet = SYMBOL_CHARSET;
  75. LogFont.lfPitchAndFamily = FF_DECORATIVE | DEFAULT_PITCH;
  76. lstrcpy(LogFont.lfFaceName, TEXT("Marlett"));
  77. HardwareWiz->hfontTextMarlett = CreateFontIndirect(&LogFont);
  78. if (!HardwareWiz->hfontTextMarlett ||
  79. !HardwareWiz->hfontTextBold ||
  80. !HardwareWiz->hfontTextBigBold )
  81. {
  82. return FALSE;
  83. }
  84. SetWindowFont(GetDlgItem(hDlg, IDC_HDWNAME), HardwareWiz->hfontTextBigBold, TRUE);
  85. SetWindowFont(GetDlgItem(hDlg, IDC_CD_TEXT), HardwareWiz->hfontTextBold, TRUE);
  86. //
  87. // An "i" in the marlett font is a small bullet.
  88. //
  89. SetWindowText(GetDlgItem(hDlg, IDC_BULLET_1), TEXT("i"));
  90. SetWindowFont(GetDlgItem(hDlg, IDC_BULLET_1), HardwareWiz->hfontTextMarlett, TRUE);
  91. SetWindowText(GetDlgItem(hDlg, IDC_BULLET_2), TEXT("i"));
  92. SetWindowFont(GetDlgItem(hDlg, IDC_BULLET_2), HardwareWiz->hfontTextMarlett, TRUE);
  93. return TRUE;
  94. }
  95. //
  96. // Wizard intro dialog proc.
  97. //
  98. INT_PTR CALLBACK
  99. HdwIntroDlgProc(
  100. HWND hDlg,
  101. UINT message,
  102. WPARAM wParam,
  103. LPARAM lParam
  104. )
  105. /*++
  106. Routine Description:
  107. Arguments:
  108. standard stuff.
  109. Return Value:
  110. INT_PTR
  111. --*/
  112. {
  113. PHARDWAREWIZ HardwareWiz;
  114. HICON hIcon;
  115. if (message == WM_INITDIALOG) {
  116. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  117. HardwareWiz = (PHARDWAREWIZ) lppsp->lParam;
  118. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  119. if (!InitHdwIntroDlgProc(hDlg, HardwareWiz)) {
  120. return FALSE;
  121. }
  122. return TRUE;
  123. }
  124. //
  125. // retrieve private data from window long (stored there during WM_INITDIALOG)
  126. //
  127. HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  128. switch (message) {
  129. case WM_DESTROY:
  130. if (HardwareWiz->hfontTextMarlett) {
  131. DeleteObject(HardwareWiz->hfontTextMarlett);
  132. HardwareWiz->hfontTextMarlett = NULL;
  133. }
  134. if (HardwareWiz->hfontTextBold) {
  135. DeleteObject(HardwareWiz->hfontTextBold);
  136. HardwareWiz->hfontTextBold = NULL;
  137. }
  138. if (HardwareWiz->hfontTextBigBold) {
  139. DeleteObject(HardwareWiz->hfontTextBigBold);
  140. HardwareWiz->hfontTextBigBold = NULL;
  141. }
  142. hIcon = (HICON)LOWORD(SendDlgItemMessage(hDlg, IDC_WARNING_ICON, STM_GETICON, 0, 0));
  143. if (hIcon) {
  144. DestroyIcon(hIcon);
  145. }
  146. break;
  147. case WM_COMMAND:
  148. break;
  149. case WM_NOTIFY: {
  150. NMHDR FAR *pnmhdr = (NMHDR FAR *)lParam;
  151. switch (pnmhdr->code) {
  152. case PSN_SETACTIVE:
  153. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_NEXT);
  154. HardwareWiz->PrevPage = IDD_ADDDEVICE_WELCOME;
  155. break;
  156. case PSN_WIZNEXT:
  157. HardwareWiz->EnterFrom = IDD_ADDDEVICE_WELCOME;
  158. break;
  159. }
  160. }
  161. break;
  162. case WM_SYSCOLORCHANGE:
  163. HdwWizPropagateMessage(hDlg, message, wParam, lParam);
  164. break;
  165. default:
  166. return FALSE;
  167. }
  168. return TRUE;
  169. }