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.

206 lines
4.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997-2001.
  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. ::ZeroMemory (&m_psp97, sizeof (PROPSHEETPAGE));
  58. m_psp.dwFlags &= ~PSP_HASHELP;
  59. memcpy (&m_psp97, &m_psp, m_psp.dwSize);
  60. m_psp97.dwSize = sizeof (PROPSHEETPAGE);
  61. if ( bHideHeader )
  62. {
  63. // for first and last page of the wizard
  64. m_psp97.dwFlags |= PSP_HIDEHEADER;
  65. }
  66. else
  67. {
  68. // for intermediate pages
  69. m_psp97.dwFlags |= PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  70. m_psp97.pszHeaderTitle = (LPCWSTR) m_szHeaderTitle;
  71. m_psp97.pszHeaderSubTitle = (LPCWSTR) m_szHeaderSubTitle;
  72. }
  73. }
  74. bool CWizard97PropertyPage::SetupFonts()
  75. {
  76. bool bReturn = false;
  77. //
  78. // Create the fonts we need based on the dialog font
  79. //
  80. NONCLIENTMETRICS ncm = {0};
  81. ncm.cbSize = sizeof (ncm);
  82. SystemParametersInfo (SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
  83. LOGFONT BigBoldLogFont = ncm.lfMessageFont;
  84. LOGFONT BoldLogFont = ncm.lfMessageFont;
  85. //
  86. // Create Big Bold Font and Bold Font
  87. //
  88. BigBoldLogFont.lfWeight = FW_BOLD;
  89. BoldLogFont.lfWeight = FW_BOLD;
  90. CString largeFontSizeString;
  91. INT largeFontSize;
  92. CString smallFontSizeString;
  93. INT smallFontSize;
  94. //
  95. // Load size and name from resources, since these may change
  96. // from locale to locale based on the size of the system font, etc.
  97. //
  98. if ( !::LoadString (AfxGetInstanceHandle (), IDS_LARGEFONTNAME,
  99. BigBoldLogFont.lfFaceName, LF_FACESIZE) )
  100. {
  101. ASSERT (0);
  102. lstrcpy (BigBoldLogFont.lfFaceName, L"Verdana");
  103. }
  104. if ( largeFontSizeString.LoadString (IDS_LARGEFONTSIZE) )
  105. {
  106. largeFontSize = wcstoul ((LPCWSTR) largeFontSizeString, NULL, 10);
  107. }
  108. else
  109. {
  110. ASSERT (0);
  111. largeFontSize = 12;
  112. }
  113. if ( !::LoadString (AfxGetInstanceHandle (), IDS_SMALLFONTNAME,
  114. BoldLogFont.lfFaceName, LF_FACESIZE) )
  115. {
  116. ASSERT (0);
  117. lstrcpy (BoldLogFont.lfFaceName, L"Verdana");
  118. }
  119. if ( smallFontSizeString.LoadString (IDS_SMALLFONTSIZE) )
  120. {
  121. smallFontSize = wcstoul ((LPCWSTR) smallFontSizeString, NULL, 10);
  122. }
  123. else
  124. {
  125. ASSERT (0);
  126. smallFontSize = 8;
  127. }
  128. CDC* pdc = GetDC ();
  129. if ( pdc )
  130. {
  131. BigBoldLogFont.lfHeight = 0 - (pdc->GetDeviceCaps (LOGPIXELSY) * largeFontSize / 72);
  132. BoldLogFont.lfHeight = 0 - (pdc->GetDeviceCaps (LOGPIXELSY) * smallFontSize / 72);
  133. BOOL bBigBold = m_bigBoldFont.CreateFontIndirect (&BigBoldLogFont);
  134. BOOL bBold = m_boldFont.CreateFontIndirect (&BoldLogFont);
  135. ReleaseDC (pdc);
  136. if ( bBigBold && bBold )
  137. bReturn = true;
  138. else
  139. {
  140. if ( bBold )
  141. {
  142. VERIFY (m_boldFont.DeleteObject());
  143. }
  144. if ( bBigBold )
  145. {
  146. VERIFY (m_bigBoldFont.DeleteObject());
  147. }
  148. }
  149. }
  150. return bReturn;
  151. }
  152. CFont& CWizard97PropertyPage::GetBoldFont()
  153. {
  154. return m_boldFont;
  155. }
  156. CFont& CWizard97PropertyPage::GetBigBoldFont()
  157. {
  158. return m_bigBoldFont;
  159. }
  160. BOOL CWizard97PropertyPage::OnInitDialog()
  161. {
  162. CPropertyPage::OnInitDialog();
  163. LONG dwExStyle = GetWindowLong (GetParent ()->m_hWnd, GWL_EXSTYLE);
  164. if ( dwExStyle & WS_EX_CONTEXTHELP )
  165. {
  166. dwExStyle &= ~WS_EX_CONTEXTHELP;
  167. SetWindowLong (GetParent ()->m_hWnd, GWL_EXSTYLE, dwExStyle);
  168. }
  169. SetupFonts ();
  170. return TRUE; // return TRUE unless you set the focus to a control
  171. // EXCEPTION: OCX Property Pages should return FALSE
  172. }