home *** CD-ROM | disk | FTP | other *** search
- // FormDeVw.cpp : implementation of the CFormDemoView class
- //
-
- #include "stdafx.h"
- #include "FormDemo.h"
-
- #include "FormDDoc.h"
- #include "FormDeVw.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CFormDemoView
-
- IMPLEMENT_DYNCREATE(CFormDemoView, CFormView)
-
- BEGIN_MESSAGE_MAP(CFormDemoView, CFormView)
- //{{AFX_MSG_MAP(CFormDemoView)
- ON_COMMAND(ID_OPTIONS_DARK, OnOptionsDark)
- ON_UPDATE_COMMAND_UI(ID_OPTIONS_DARK, OnUpdateOptionsDark)
- ON_COMMAND(ID_OPTIONS_LIGHT, OnOptionsLight)
- ON_UPDATE_COMMAND_UI(ID_OPTIONS_LIGHT, OnUpdateOptionsLight)
- ON_BN_CLICKED(IDC_RED, OnRed)
- ON_BN_CLICKED(IDC_GREEN, OnGreen)
- ON_BN_CLICKED(IDC_BLUE, OnBlue)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CFormDemoView construction/destruction
-
- CFormDemoView::CFormDemoView()
- : CFormView(CFormDemoView::IDD)
- {
- //{{AFX_DATA_INIT(CFormDemoView)
- m_Red = FALSE;
- m_Green = FALSE;
- m_Blue = FALSE;
- //}}AFX_DATA_INIT
- // TODO: add construction code here
-
- m_Intensity = INT_LIGHT;
- }
-
- CFormDemoView::~CFormDemoView()
- {
- }
-
- void CFormDemoView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CFormDemoView)
- DDX_Check(pDX, IDC_RED, m_Red);
- DDX_Check(pDX, IDC_GREEN, m_Green);
- DDX_Check(pDX, IDC_BLUE, m_Blue);
- //}}AFX_DATA_MAP
- }
-
- BOOL CFormDemoView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
-
- return CFormView::PreCreateWindow(cs);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CFormDemoView diagnostics
-
- #ifdef _DEBUG
- void CFormDemoView::AssertValid() const
- {
- CFormView::AssertValid();
- }
-
- void CFormDemoView::Dump(CDumpContext& dc) const
- {
- CFormView::Dump(dc);
- }
-
- CFormDemoDoc* CFormDemoView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFormDemoDoc)));
- return (CFormDemoDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CFormDemoView message handlers
-
- void CFormDemoView::OnOptionsDark()
- {
- // TODO: Add your command handler code here
- m_Intensity = INT_DARK;
-
- CClientDC ClientDC (this);
- OnPrepareDC (&ClientDC);
- CRect Rect = m_RectSample;
- ClientDC.LPtoDP (&Rect);
- InvalidateRect (&Rect);
- UpdateWindow ();
- }
-
- void CFormDemoView::OnUpdateOptionsDark(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetRadio (m_Intensity == INT_DARK);
- }
-
- void CFormDemoView::OnOptionsLight()
- {
- // TODO: Add your command handler code here
- m_Intensity = INT_LIGHT;
-
- CClientDC ClientDC (this);
- OnPrepareDC (&ClientDC);
- CRect Rect = m_RectSample;
- ClientDC.LPtoDP (&Rect);
- InvalidateRect (&Rect);
- UpdateWindow ();
- }
-
- void CFormDemoView::OnUpdateOptionsLight(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetRadio (m_Intensity == INT_LIGHT);
- }
-
- void CFormDemoView::OnRed()
- {
- // TODO: Add your control notification handler code here
- m_Red = IsDlgButtonChecked (IDC_RED);
-
- CClientDC ClientDC (this);
- OnPrepareDC (&ClientDC);
- CRect Rect = m_RectSample;
- ClientDC.LPtoDP (&Rect);
- InvalidateRect (&Rect);
- UpdateWindow ();
- }
-
- void CFormDemoView::OnGreen()
- {
- // TODO: Add your control notification handler code here
- m_Green = IsDlgButtonChecked (IDC_GREEN);
-
- CClientDC ClientDC (this);
- OnPrepareDC (&ClientDC);
- CRect Rect = m_RectSample;
- ClientDC.LPtoDP (&Rect);
- InvalidateRect (&Rect);
- UpdateWindow ();
- }
-
- void CFormDemoView::OnBlue()
- {
- // TODO: Add your control notification handler code here
- m_Blue = IsDlgButtonChecked (IDC_BLUE);
-
- CClientDC ClientDC (this);
- OnPrepareDC (&ClientDC);
- CRect Rect = m_RectSample;
- ClientDC.LPtoDP (&Rect);
- InvalidateRect (&Rect);
- UpdateWindow ();
- }
-
- void CFormDemoView::OnDraw(CDC* pDC)
- {
- // TODO: Add your specialized code here and/or call the base class
- COLORREF Color = RGB
- (m_Red ? (m_Intensity==INT_DARK ? 128 : 255) : 0,
- m_Green ? (m_Intensity==INT_DARK ? 128 : 255) : 0,
- m_Blue ? (m_Intensity==INT_DARK ? 128 : 255) : 0);
- CBrush Brush (Color);
- pDC->FillRect (&m_RectSample, &Brush);
- }
-
- void CFormDemoView::OnInitialUpdate()
- {
- CFormView::OnInitialUpdate();
-
- // TODO: Add your specialized code here and/or call the base class
- GetDlgItem (IDC_SAMPLE)->GetWindowRect (&m_RectSample);
- ScreenToClient (&m_RectSample);
- int Border = (m_RectSample.right - m_RectSample.left) / 8;
- m_RectSample.InflateRect (-Border, -Border);
- }
-