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.

208 lines
4.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: csw97ppg.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // csw97ppg.cpp : implementation file
  11. #include <pch.cpp>
  12. #pragma hdrstop
  13. #include "prsht.h"
  14. #include "csw97ppg.h"
  15. //#include "resource.h"
  16. #ifdef _DEBUG
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CWizard97PropertyPage property page
  22. //IMPLEMENT_DYNCREATE(CWizard97PropertyPage, CPropertyPage)
  23. CWizard97PropertyPage::CWizard97PropertyPage() :
  24. PropertyPage(),
  25. m_pWiz(NULL)
  26. {
  27. ASSERT(0); // default constructor - should never be called
  28. }
  29. CWizard97PropertyPage::CWizard97PropertyPage(
  30. HINSTANCE hInstance,
  31. UINT nIDTemplate,
  32. UINT rgnIDFont[CSW97PG_COUNT]) :
  33. PropertyPage(nIDTemplate),
  34. m_pWiz(NULL)
  35. {
  36. //{{AFX_DATA_INIT(CWizard97PropertyPage)
  37. // NOTE: the ClassWizard will add member initialization here
  38. //}}AFX_DATA_INIT
  39. m_hInstance = hInstance;
  40. CopyMemory(m_rgnIDFont, rgnIDFont, sizeof(m_rgnIDFont));
  41. }
  42. CWizard97PropertyPage::~CWizard97PropertyPage()
  43. {
  44. }
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CWizard97PropertyPage message handlers
  47. void
  48. CWizard97PropertyPage::InitWizard97(
  49. bool bHideHeader)
  50. {
  51. ZeroMemory(&m_psp97, sizeof(PROPSHEETPAGE));
  52. CopyMemory(&m_psp97, &m_psp, m_psp.dwSize);
  53. m_psp97.dwSize = sizeof(PROPSHEETPAGE);
  54. if (bHideHeader)
  55. {
  56. // for first and last page of the wizard
  57. m_psp97.dwFlags |= PSP_HIDEHEADER;
  58. }
  59. else
  60. {
  61. // for intermediate pages
  62. m_psp97.dwFlags |= PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  63. m_psp97.pszHeaderTitle = (LPCTSTR) m_szHeaderTitle;
  64. m_psp97.pszHeaderSubTitle = (LPCTSTR) m_szHeaderSubTitle;
  65. }
  66. }
  67. BOOL
  68. CWizard97PropertyPage::SetupFonts()
  69. {
  70. BOOL bReturn = FALSE;
  71. //
  72. // Create the fonts we need based on the dialog font
  73. //
  74. NONCLIENTMETRICS ncm = {0};
  75. ncm.cbSize = sizeof(ncm);
  76. SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
  77. LOGFONT BigBoldLogFont = ncm.lfMessageFont;
  78. LOGFONT BoldLogFont = ncm.lfMessageFont;
  79. //
  80. // Create Big Bold Font and Bold Font
  81. //
  82. BigBoldLogFont.lfWeight = FW_BOLD;
  83. BoldLogFont.lfWeight = FW_BOLD;
  84. WCHAR largeFontSizeString[24];
  85. INT largeFontSize;
  86. WCHAR smallFontSizeString[24];
  87. INT smallFontSize;
  88. //
  89. // Load size and name from resources, since these may change
  90. // from locale to locale based on the size of the system font, etc.
  91. //
  92. if (!::LoadString(
  93. m_hInstance,
  94. m_rgnIDFont[CSW97PG_IDLARGEFONTNAME],
  95. BigBoldLogFont.lfFaceName,
  96. LF_FACESIZE))
  97. {
  98. ASSERT(0);
  99. lstrcpy(BigBoldLogFont.lfFaceName, L"MS Shell Dlg");
  100. }
  101. if (::LoadStringW(
  102. m_hInstance,
  103. m_rgnIDFont[CSW97PG_IDLARGEFONTSIZE],
  104. largeFontSizeString,
  105. ARRAYSIZE(largeFontSizeString)))
  106. {
  107. largeFontSize = wcstoul(largeFontSizeString, NULL, 10);
  108. }
  109. else
  110. {
  111. ASSERT(0);
  112. largeFontSize = 12;
  113. }
  114. if (!::LoadString(
  115. m_hInstance,
  116. m_rgnIDFont[CSW97PG_IDSMALLFONTNAME],
  117. BoldLogFont.lfFaceName,
  118. LF_FACESIZE))
  119. {
  120. ASSERT(0);
  121. lstrcpy(BoldLogFont.lfFaceName, L"MS Shell Dlg");
  122. }
  123. if (::LoadStringW(
  124. m_hInstance,
  125. m_rgnIDFont[CSW97PG_IDSMALLFONTSIZE],
  126. smallFontSizeString,
  127. ARRAYSIZE(smallFontSizeString)))
  128. {
  129. smallFontSize = wcstoul(smallFontSizeString, NULL, 10);
  130. }
  131. else
  132. {
  133. ASSERT(0);
  134. smallFontSize = 8;
  135. }
  136. HDC hdc = GetDC(m_hWnd);
  137. if (hdc)
  138. {
  139. BigBoldLogFont.lfHeight = 0 - (GetDeviceCaps(hdc, LOGPIXELSY) * largeFontSize / 72);
  140. BoldLogFont.lfHeight = 0 - (GetDeviceCaps(hdc, LOGPIXELSY) * smallFontSize / 72);
  141. BOOL bBigBold = m_bigBoldFont.CreateFontIndirect(&BigBoldLogFont);
  142. BOOL bBold = m_boldFont.CreateFontIndirect(&BoldLogFont);
  143. ReleaseDC(m_hWnd, hdc);
  144. if (bBigBold && bBold)
  145. {
  146. bReturn = TRUE;
  147. }
  148. }
  149. return bReturn;
  150. }
  151. HFONT
  152. CWizard97PropertyPage::GetBoldFont()
  153. {
  154. return m_boldFont;
  155. }
  156. HFONT
  157. CWizard97PropertyPage::GetBigBoldFont()
  158. {
  159. return m_bigBoldFont;
  160. }
  161. BOOL CWizard97PropertyPage::OnInitDialog()
  162. {
  163. PropertyPage::OnInitDialog();
  164. SetupFonts();
  165. return TRUE; // return TRUE unless you set the focus to a control
  166. // EXCEPTION: OCX Property Pages should return FALSE
  167. }