home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / ctlhtmlc / options.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-11  |  4.7 KB  |  181 lines

  1. /*---------------------------------------------------------------------------*\
  2.  | Options.cpp  - CtlHTML(tm) Control Library Test Program                   |
  3.  |                Windmill Point Software, Alburg, VT 05440                  |
  4.  |                Copyright (c) 1999, Windmill Point Software                |
  5.  |                All Rights Reserved.                                       |
  6. \*---------------------------------------------------------------------------*/
  7.  
  8. #include "stdafx.h"
  9. #include "CtlHTML Demo.h"
  10. #include "DevUI.h"
  11. #include "Options.h"
  12. #include "..\CtlHtml.h"
  13.  
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19.  
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CGeneralOptions property page
  22.  
  23. IMPLEMENT_DYNCREATE(CGeneralOptions, CPropertyPage)
  24.  
  25. BEGIN_MESSAGE_MAP(CGeneralOptions, CPropertyPage)
  26.     //{{AFX_MSG_MAP(CGeneralOptions)
  27.     ON_WM_ACTIVATE()
  28.     ON_BN_CLICKED(IDC_FONT_BROWSE, OnFontBrowse)
  29.     //}}AFX_MSG_MAP
  30. END_MESSAGE_MAP()
  31.  
  32. CGeneralOptions::CGeneralOptions() : CPropertyPage(CGeneralOptions::IDD)
  33. {
  34.     //{{AFX_DATA_INIT(CGeneralOptions)
  35.     m_RightJustify = -1;
  36.     m_FontSize = 0;
  37.     m_Typeface = _T("");
  38.     m_DisableControls = FALSE;
  39.     m_DitherGraphics = FALSE;
  40.     m_HelpPath = _T("");
  41.     m_UseDisabled3D = FALSE;
  42.     //}}AFX_DATA_INIT
  43. }
  44.  
  45. CGeneralOptions::~CGeneralOptions()
  46. {
  47. }
  48.  
  49. void CGeneralOptions::DoDataExchange(CDataExchange* pDX)
  50. {
  51.     CPropertyPage::DoDataExchange(pDX);
  52.     //{{AFX_DATA_MAP(CGeneralOptions)
  53.     DDX_Radio(pDX, IDC_CENTER, m_RightJustify);
  54.     DDX_Text(pDX, IDC_FONT_SIZE, m_FontSize);
  55.     DDV_MinMaxUInt(pDX, m_FontSize, 6, 24);
  56.     DDX_Text(pDX, IDC_TYPEFACE, m_Typeface);
  57.     DDX_Check(pDX, IDC_DISABLE_CONTROLS, m_DisableControls);
  58.     DDX_Check(pDX, IDC_DITHER_GRAPHICS, m_DitherGraphics);
  59.     DDX_Text(pDX, IDC_HELP_PATH, m_HelpPath);
  60.     DDX_Check(pDX, IDC_USE_3D, m_UseDisabled3D);
  61.     //}}AFX_DATA_MAP
  62. }
  63.  
  64. void CGeneralOptions::OnFontBrowse() 
  65. {
  66.    CClientDC dc(this);
  67.    LOGFONT lf;
  68.  
  69.    // init font info
  70.    ZeroMemory(&lf, sizeof(lf));
  71.    lf.lfHeight = -MulDiv(m_FontSize, dc.GetDeviceCaps(LOGPIXELSY), 72);
  72.    lf.lfWeight = FW_NORMAL;
  73.    _tcscpy(lf.lfFaceName, m_Typeface);
  74.  
  75.    // display font common dialog
  76.    CFontDialog dialog(&lf);
  77.    if (dialog.DoModal() == IDOK)
  78.    {
  79.       m_Typeface = dialog.GetFaceName();
  80.       m_FontSize = dialog.GetSize() / 10;
  81.  
  82.       CWnd   *pWnd;
  83.       CString temp;
  84.  
  85.       temp.Format(_T("%d"), m_FontSize);
  86.       if ((pWnd = GetDlgItem(IDC_TYPEFACE)) != 0)
  87.          pWnd->SetWindowText(m_Typeface);
  88.       else
  89.          ASSERT(FALSE);
  90.  
  91.       if ((pWnd = GetDlgItem(IDC_FONT_SIZE)) != 0)
  92.          pWnd->SetWindowText(temp);
  93.       else
  94.          ASSERT(FALSE);
  95.    }
  96. }
  97.  
  98. BOOL CGeneralOptions::OnInitDialog() 
  99. {
  100.     CPropertyPage::OnInitDialog();
  101.  
  102.    CSpinButtonCtrl *pSpin;
  103.  
  104.    if ((pSpin = (CSpinButtonCtrl *)GetDlgItem(IDC_FONTSIZE_SPIN)) != 0)
  105.    {
  106.       ASSERT_VALID(pSpin);
  107.       pSpin->SetRange(6, 24);
  108.    }
  109.    else
  110.       ASSERT(FALSE);
  111.     
  112.     return TRUE;
  113. }
  114.  
  115. void CGeneralOptions::OnActivate (UINT nState, CWnd* pWndOther, BOOL bMinimized)
  116. {
  117.    CPropertyPage::OnActivate(nState, pWndOther, bMinimized);
  118.    if (DisableControls)
  119.       CtlHTMLDialogEnable(m_hWnd, nState != WA_INACTIVE);
  120. }
  121.  
  122. /////////////////////////////////////////////////////////////////////////////
  123. // COptions
  124.  
  125. IMPLEMENT_DYNAMIC(COptions, CMcPropertySheet)
  126.  
  127. BEGIN_MESSAGE_MAP(COptions, CMcPropertySheet)
  128.     //{{AFX_MSG_MAP(COptions)
  129.     ON_WM_ACTIVATE()
  130.     ON_WM_DESTROY()
  131.     //}}AFX_MSG_MAP
  132. END_MESSAGE_MAP()
  133.  
  134. COptions::COptions(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
  135.     :CMcPropertySheet(nIDCaption, pParentWnd, iSelectPage)
  136. {
  137.    AddPage(&m_General);
  138. }
  139.  
  140. COptions::COptions(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
  141.     :CMcPropertySheet(pszCaption, pParentWnd, iSelectPage)
  142. {
  143.    AddPage(&m_General);
  144. }
  145.  
  146. COptions::~COptions()
  147. {
  148. }
  149.  
  150. BOOL COptions::OnInitDialog() 
  151. {
  152.    // remove the Apply button
  153.    RemoveApplyButton();
  154.  
  155.    // init the dialog
  156.     BOOL bResult = CMcPropertySheet::OnInitDialog();
  157.  
  158.    // handle window placement    
  159.    CMcWindowPlacement wp;
  160.    wp.RestoreWindowPlacement(_T("Options"), _T("WindowPlacement"), this, TRUE);
  161.  
  162.    // init the dialog
  163.     return bResult;
  164. }
  165.  
  166. void COptions::OnDestroy() 
  167. {
  168.    // handle window placement    
  169.    CMcWindowPlacement wp;
  170.    wp.SaveWindowPlacement(_T("Options"), _T("WindowPlacement"), this);
  171.  
  172.     CMcPropertySheet::OnDestroy();
  173. }
  174.  
  175. void COptions::OnActivate (UINT nState, CWnd* pWndOther, BOOL bMinimized)
  176. {
  177.    CMcPropertySheet::OnActivate(nState, pWndOther, bMinimized);
  178.    if (DisableControls)
  179.       CtlHTMLDialogEnable(m_hWnd, nState != WA_INACTIVE);
  180. }
  181.