home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / general / propdlg / colorpge.cpp next >
C/C++ Source or Header  |  1998-03-26  |  3KB  |  87 lines

  1. // colorpge.cpp : implementation file
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "propdlg.h"
  15. #include "stylepge.h"
  16. #include "colorpge.h"
  17. #include "shapeobj.h"
  18. #include "preview.h"
  19. #include "propsht.h"
  20. #include "propsht2.h"
  21.  
  22. #ifdef _DEBUG
  23. #undef THIS_FILE
  24. static char BASED_CODE THIS_FILE[] = __FILE__;
  25. #endif
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CColorPage property page
  29.  
  30. CColorPage::CColorPage()
  31.     : CPropertyPage(CColorPage::IDD)
  32. {
  33.     //{{AFX_DATA_INIT(CColorPage)
  34.     //}}AFX_DATA_INIT
  35.     m_nColor = black;
  36. }
  37.  
  38. void CColorPage::DoDataExchange(CDataExchange* pDX)
  39. {
  40.     CPropertyPage::DoDataExchange(pDX);
  41.     //{{AFX_DATA_MAP(CColorPage)
  42.     DDX_Radio(pDX, IDC_BLACK, m_nColor);
  43.     //}}AFX_DATA_MAP
  44. }
  45.  
  46. void CColorPage::OnColorClicked(UINT /*nCmdID*/)
  47. {
  48.     // The CColorPage property page is used for both the
  49.     // CModalShapePropSheet and the CModelessShapePropSheet.
  50.     // Both these versions of the property sheet share a common
  51.     // feature that they immediately update a shape.  In the
  52.     // case of CModalShapePropSheet, the shape is in the preview
  53.     // window.  In the case of CModelessShapePropSheet, the shape
  54.     // is the currently selected shape in the view.
  55.  
  56.     CPropertySheet* pSheet = STATIC_DOWNCAST(CPropertySheet, GetParent());
  57.  
  58.     CModalShapePropSheet* pModalSheet =
  59.         DYNAMIC_DOWNCAST(CModalShapePropSheet, pSheet);
  60.     if (pModalSheet != NULL)
  61.     {
  62.         UpdateData();
  63.         pModalSheet->UpdateShapePreview();
  64.         SetModified(); // enable Apply Now button
  65.     }
  66.  
  67.     CModelessShapePropSheet* pModelessSheet =
  68.         DYNAMIC_DOWNCAST(CModelessShapePropSheet, pSheet);
  69.     if (pModelessSheet != NULL)
  70.     {
  71.         UpdateData();
  72.         CFrameWnd* pFrameWnd = STATIC_DOWNCAST(CFrameWnd, AfxGetMainWnd());
  73.         CView* pView = pFrameWnd->GetActiveFrame()->GetActiveView();
  74.         pView->SendMessage(WM_USER_CHANGE_OBJECT_PROPERTIES, 0, 0);
  75.     }
  76. }
  77.  
  78. BEGIN_MESSAGE_MAP(CColorPage, CPropertyPage)
  79.     ON_CONTROL_RANGE(BN_CLICKED, IDC_BLACK, IDC_BLUE, OnColorClicked)
  80.     //{{AFX_MSG_MAP(CColorPage)
  81.         // NOTE: the ClassWizard will add message map macros here
  82.     //}}AFX_MSG_MAP
  83. END_MESSAGE_MAP()
  84.  
  85. /////////////////////////////////////////////////////////////////////////////
  86. // CColorPage message handlers
  87.