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.

217 lines
5.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997-2002.
  5. //
  6. // File: Wiz97PPg.cpp
  7. //
  8. // Contents:
  9. //
  10. //----------------------------------------------------------------------------
  11. // Wiz97PPg.cpp : implementation file
  12. //
  13. #include "stdafx.h"
  14. #include "Wiz97PPg.h"
  15. #ifdef _DEBUG
  16. #ifndef ALPHA
  17. #define new DEBUG_NEW
  18. #endif
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CWizard97PropertyPage property page
  24. IMPLEMENT_DYNCREATE(CWizard97PropertyPage, CPropertyPage)
  25. CWizard97PropertyPage::CWizard97PropertyPage ()
  26. : CPropertyPage (),
  27. m_pWiz (0)
  28. {
  29. ASSERT (0); // default constructor - should never be called
  30. }
  31. CWizard97PropertyPage::CWizard97PropertyPage(UINT nIDTemplate) :
  32. CPropertyPage(nIDTemplate),
  33. m_pWiz (0)
  34. {
  35. //{{AFX_DATA_INIT(CWizard97PropertyPage)
  36. // NOTE: the ClassWizard will add member initialization here
  37. //}}AFX_DATA_INIT
  38. }
  39. CWizard97PropertyPage::~CWizard97PropertyPage()
  40. {
  41. }
  42. void CWizard97PropertyPage::DoDataExchange(CDataExchange* pDX)
  43. {
  44. CPropertyPage::DoDataExchange(pDX);
  45. //{{AFX_DATA_MAP(CWizard97PropertyPage)
  46. // NOTE: the ClassWizard will add DDX and DDV calls here
  47. //}}AFX_DATA_MAP
  48. }
  49. BEGIN_MESSAGE_MAP(CWizard97PropertyPage, CPropertyPage)
  50. //{{AFX_MSG_MAP(CWizard97PropertyPage)
  51. //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CWizard97PropertyPage message handlers
  55. void CWizard97PropertyPage::InitWizard97(bool bHideHeader)
  56. {
  57. // security review 2/27/2002 BryanWal ok
  58. ::ZeroMemory (&m_psp97, sizeof (m_psp97));
  59. m_psp.dwFlags &= ~PSP_HASHELP;
  60. ASSERT (sizeof (m_psp97) >= m_psp.dwSize);
  61. if ( sizeof (m_psp97) < m_psp.dwSize )
  62. return;
  63. // security review 2/27/2002 BryanWal ok
  64. memcpy (&m_psp97, &m_psp, m_psp.dwSize);
  65. m_psp97.dwSize = sizeof (PROPSHEETPAGE);
  66. if ( bHideHeader )
  67. {
  68. // for first and last page of the wizard
  69. m_psp97.dwFlags |= PSP_HIDEHEADER;
  70. }
  71. else
  72. {
  73. // for intermediate pages
  74. m_psp97.dwFlags |= PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  75. m_psp97.pszHeaderTitle = (LPCWSTR) m_szHeaderTitle;
  76. m_psp97.pszHeaderSubTitle = (LPCWSTR) m_szHeaderSubTitle;
  77. }
  78. }
  79. bool CWizard97PropertyPage::SetupFonts()
  80. {
  81. bool bReturn = false;
  82. //
  83. // Create the fonts we need based on the dialog font
  84. //
  85. NONCLIENTMETRICS ncm = {0};
  86. ncm.cbSize = sizeof (ncm);
  87. SystemParametersInfo (SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
  88. LOGFONT BigBoldLogFont = ncm.lfMessageFont;
  89. LOGFONT BoldLogFont = ncm.lfMessageFont;
  90. //
  91. // Create Big Bold Font and Bold Font
  92. //
  93. BigBoldLogFont.lfWeight = FW_BOLD;
  94. BoldLogFont.lfWeight = FW_BOLD;
  95. CString largeFontSizeString;
  96. INT largeFontSize;
  97. CString smallFontSizeString;
  98. INT smallFontSize;
  99. //
  100. // Load size and name from resources, since these may change
  101. // from locale to locale based on the size of the system font, etc.
  102. //
  103. static PCWSTR pwszAlternateFont = L"Verdana";
  104. static size_t cchFont = wcslen (pwszAlternateFont);
  105. if ( !::LoadString (AfxGetInstanceHandle (), IDS_LARGEFONTNAME,
  106. BigBoldLogFont.lfFaceName, LF_FACESIZE) )
  107. {
  108. ASSERT (0);
  109. // security review 2/27/2002 BryanWal ok
  110. if ( cchFont < LF_FACESIZE )
  111. wcscpy (BigBoldLogFont.lfFaceName, pwszAlternateFont);
  112. }
  113. if ( largeFontSizeString.LoadString (IDS_LARGEFONTSIZE) )
  114. {
  115. largeFontSize = wcstoul ((LPCWSTR) largeFontSizeString, NULL, 10);
  116. }
  117. else
  118. {
  119. ASSERT (0);
  120. largeFontSize = 12;
  121. }
  122. if ( !::LoadString (AfxGetInstanceHandle (), IDS_SMALLFONTNAME,
  123. BoldLogFont.lfFaceName, LF_FACESIZE) )
  124. {
  125. ASSERT (0);
  126. if ( cchFont < LF_FACESIZE )
  127. wcscpy (BoldLogFont.lfFaceName, pwszAlternateFont);
  128. }
  129. if ( smallFontSizeString.LoadString (IDS_SMALLFONTSIZE) )
  130. {
  131. smallFontSize = wcstoul ((LPCWSTR) smallFontSizeString, NULL, 10);
  132. }
  133. else
  134. {
  135. ASSERT (0);
  136. smallFontSize = 8;
  137. }
  138. CDC* pdc = GetDC ();
  139. if ( pdc )
  140. {
  141. BigBoldLogFont.lfHeight = 0 - (pdc->GetDeviceCaps (LOGPIXELSY) * largeFontSize / 72);
  142. BoldLogFont.lfHeight = 0 - (pdc->GetDeviceCaps (LOGPIXELSY) * smallFontSize / 72);
  143. BOOL bBigBold = m_bigBoldFont.CreateFontIndirect (&BigBoldLogFont);
  144. BOOL bBold = m_boldFont.CreateFontIndirect (&BoldLogFont);
  145. ReleaseDC (pdc);
  146. if ( bBigBold && bBold )
  147. bReturn = true;
  148. else
  149. {
  150. if ( bBold )
  151. {
  152. VERIFY (m_boldFont.DeleteObject());
  153. }
  154. if ( bBigBold )
  155. {
  156. VERIFY (m_bigBoldFont.DeleteObject());
  157. }
  158. }
  159. }
  160. return bReturn;
  161. }
  162. CFont& CWizard97PropertyPage::GetBoldFont()
  163. {
  164. return m_boldFont;
  165. }
  166. CFont& CWizard97PropertyPage::GetBigBoldFont()
  167. {
  168. return m_bigBoldFont;
  169. }
  170. BOOL CWizard97PropertyPage::OnInitDialog()
  171. {
  172. CPropertyPage::OnInitDialog();
  173. LONG dwExStyle = GetWindowLong (GetParent ()->m_hWnd, GWL_EXSTYLE);
  174. if ( dwExStyle & WS_EX_CONTEXTHELP )
  175. {
  176. dwExStyle &= ~WS_EX_CONTEXTHELP;
  177. SetWindowLong (GetParent ()->m_hWnd, GWL_EXSTYLE, dwExStyle);
  178. }
  179. SetupFonts ();
  180. return TRUE; // return TRUE unless you set the focus to a control
  181. // EXCEPTION: OCX Property Pages should return FALSE
  182. }