home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c06 / lab05 / ex03 / pages.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.6 KB  |  162 lines

  1. // Pages.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "resource.h"
  6. #include "Pages.h"
  7.  
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char BASED_CODE THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. IMPLEMENT_DYNCREATE(CColorPage, CPropertyPage)
  14. IMPLEMENT_DYNCREATE(CComparePage, CPropertyPage)
  15. IMPLEMENT_DYNCREATE(CFontPage, CPropertyPage)
  16.  
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CColorPage property page
  20.  
  21. CColorPage::CColorPage() : CPropertyPage(CColorPage::IDD)
  22. {
  23.     //{{AFX_DATA_INIT(CColorPage)
  24.         // NOTE: the ClassWizard will add member initialization here
  25.     //}}AFX_DATA_INIT
  26. }
  27.  
  28. CColorPage::~CColorPage()
  29. {
  30. }
  31.  
  32. void CColorPage::DoDataExchange(CDataExchange* pDX)
  33. {
  34.     CPropertyPage::DoDataExchange(pDX);
  35.     //{{AFX_DATA_MAP(CColorPage)
  36.         // NOTE: the ClassWizard will add DDX and DDV calls here
  37.     //}}AFX_DATA_MAP
  38. }
  39.  
  40.  
  41. BEGIN_MESSAGE_MAP(CColorPage, CPropertyPage)
  42.     //{{AFX_MSG_MAP(CColorPage)
  43.         // NOTE: the ClassWizard will add message map macros here
  44.     //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46.  
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CComparePage property page
  50.  
  51. CComparePage::CComparePage() : CPropertyPage(CComparePage::IDD)
  52. {
  53.     //{{AFX_DATA_INIT(CComparePage)
  54.     m_bIgnoreCase = FALSE;
  55.     m_bIgnoreWhiteSpace = FALSE;
  56.     //}}AFX_DATA_INIT
  57. }
  58.  
  59. CComparePage::~CComparePage()
  60. {
  61. }
  62.  
  63. void CComparePage::DoDataExchange(CDataExchange* pDX)
  64. {
  65.     CPropertyPage::DoDataExchange(pDX);
  66.     //{{AFX_DATA_MAP(CComparePage)
  67.     DDX_Control(pDX, IDC_TRACKBAR1, m_Slider);
  68.     DDX_Check(pDX, IDC_CHECK_IGNORE_CASE, m_bIgnoreCase);
  69.     DDX_Check(pDX, IDC_CHECK_IGNORE_WHITE, m_bIgnoreWhiteSpace);
  70.     //}}AFX_DATA_MAP
  71.  
  72.     if (pDX->m_bSaveAndValidate)
  73.     {
  74.         m_uReadAheadOptLevel = m_Slider.GetPos();
  75.     }
  76.     else
  77.     {
  78.         m_Slider.SetPos(m_uReadAheadOptLevel);
  79.     }
  80. }
  81.  
  82.  
  83. BEGIN_MESSAGE_MAP(CComparePage, CPropertyPage)
  84.     //{{AFX_MSG_MAP(CComparePage)
  85.     //}}AFX_MSG_MAP
  86. END_MESSAGE_MAP()
  87.  
  88. BOOL CComparePage::OnInitDialog() 
  89. {
  90.     CPropertyPage::OnInitDialog();
  91.     
  92.     m_Slider.SetRange(0, 4);
  93.     
  94.     return TRUE;  // return TRUE unless you set the focus to a control
  95.                   // EXCEPTION: OCX Property Pages should return FALSE
  96. }
  97.  
  98. /////////////////////////////////////////////////////////////////////////////
  99. // CFontPage property page
  100.  
  101. CFontPage::CFontPage() : CPropertyPage(CFontPage::IDD)
  102. {
  103.     //{{AFX_DATA_INIT(CFontPage)
  104.     m_FontName = _T("");
  105.     m_FontSize = _T("");
  106.     //}}AFX_DATA_INIT
  107. }
  108.  
  109. CFontPage::~CFontPage()
  110. {
  111. }
  112.  
  113. void CFontPage::DoDataExchange(CDataExchange* pDX)
  114. {
  115.     if (!pDX->m_bSaveAndValidate) //updating the controls
  116.     {
  117.         //    Update FaceName and Size CString variables that
  118.         //    are assocated with statics on the page.
  119.         m_FontName = m_CharacterFormat.szFaceName;
  120.         wsprintf(m_FontSize.GetBufferSetLength(32), "%ld Points", m_CharacterFormat.yHeight/20);
  121.         m_FontSize.ReleaseBuffer();
  122.     }
  123.     CPropertyPage::DoDataExchange(pDX);
  124.     //{{AFX_DATA_MAP(CFontPage)
  125.     DDX_Text(pDX, IDC_STATIC_FONT, m_FontName);
  126.     DDX_Text(pDX, IDC_STATIC_SIZE, m_FontSize);
  127.     //}}AFX_DATA_MAP
  128.  
  129. }
  130.  
  131.  
  132. BEGIN_MESSAGE_MAP(CFontPage, CPropertyPage)
  133.     //{{AFX_MSG_MAP(CFontPage)
  134.     ON_BN_CLICKED(IDC_BUTTON_FONT, OnButtonFont)
  135.     //}}AFX_MSG_MAP
  136. END_MESSAGE_MAP()
  137.  
  138.  
  139.  
  140.  
  141. void CFontPage::OnButtonFont() 
  142. {
  143.     CFontDialog    dlg(m_CharacterFormat);
  144.  
  145.     if(dlg.DoModal() == IDOK)
  146.     {
  147.         dlg.GetCharFormat(m_CharacterFormat);
  148.         UpdateData(FALSE);
  149.     }    
  150. }
  151.  
  152. void CFontPage::SetCharacterFormat(CHARFORMAT& CharFormat)
  153. {
  154.     m_CharacterFormat = CharFormat; 
  155. }
  156.     
  157.  
  158. void CFontPage::GetCharacterFormat(CHARFORMAT& CharFormat) const 
  159. {
  160.     CharFormat = m_CharacterFormat; 
  161. }
  162.