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 / preview.cpp < prev    next >
C/C++ Source or Header  |  1998-03-26  |  2KB  |  59 lines

  1. // preview.cpp : implementation of the CModalShapePropSheet class
  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 "preview.h"
  15. #include "resource.h"
  16. #include "colorpge.h"
  17. #include "stylepge.h"
  18. #include "shapeobj.h"
  19. #include "propsht.h"
  20.  
  21. BEGIN_MESSAGE_MAP(CShapePreviewWnd, CWnd)
  22. //{{AFX_MSG_MAP(CShapePreviewWnd)
  23.     ON_WM_PAINT()
  24.     ON_WM_ERASEBKGND()
  25. //}}AFX_MSG_MAP
  26. END_MESSAGE_MAP()
  27.  
  28. CShapePreviewWnd::CShapePreviewWnd()
  29. {
  30. }
  31.  
  32. void CShapePreviewWnd::OnPaint()
  33. {
  34.     CPaintDC dc(this);
  35.     CModalShapePropSheet* pShapePropSheet =
  36.         STATIC_DOWNCAST(CModalShapePropSheet, GetParent());
  37.     CRect rect;
  38.     GetClientRect(rect);
  39.     CShape shape(
  40.         (SHAPE_COLOR_ENUM)pShapePropSheet->m_colorPage.m_nColor,
  41.         (SHAPE_STYLE)pShapePropSheet->m_stylePage.m_nShapeStyle,
  42.         rect);
  43.     shape.Draw(&dc, FALSE);
  44. }
  45.  
  46. BOOL CShapePreviewWnd::OnEraseBkgnd(CDC* pDC)
  47. {
  48.     // Use the same background color as that of the dialog
  49.     //  (property sheet).
  50.  
  51.     CWnd* pParentWnd = GetParent();
  52.     HBRUSH hBrush = (HBRUSH)pParentWnd->SendMessage(WM_CTLCOLORDLG,
  53.         (WPARAM)pDC->m_hDC, (LPARAM)pParentWnd->m_hWnd);
  54.     CRect rect;
  55.     GetClientRect(rect);
  56.     pDC->FillRect(&rect, CBrush::FromHandle(hBrush));
  57.     return TRUE;
  58. }
  59.