home *** CD-ROM | disk | FTP | other *** search
- // ChildFrm.cpp : implementation of the CChildFrame class
- //
-
- #include "stdafx.h"
- #include "MDI2ViewsB.h"
-
- #include "mdi2viewsBdoc.h"
- #include "ChildFrm.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- const COLORREF BLACK=RGB(0,0,0);
- const COLORREF RED=RGB(255,0,0);
- const COLORREF GREEN=RGB(0,255,0);
- const COLORREF BLUE=RGB(0,0,255);
-
- /////////////////////////////////////////////////////////////////////////////
- // CChildFrame
-
- IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
-
- BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
- //{{AFX_MSG_MAP(CChildFrame)
- //}}AFX_MSG_MAP
- ON_COMMAND_RANGE(ID_COLORS_BLACK, ID_COLORS_BLUE, OnColors)
- ON_UPDATE_COMMAND_UI_RANGE(ID_COLORS_BLACK, ID_COLORS_BLUE, OnUpdateColors)
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CChildFrame construction/destruction
-
- CChildFrame::CChildFrame()
- {
- }
-
- CChildFrame::~CChildFrame()
- {
- }
-
- BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- return CMDIChildWnd::PreCreateWindow(cs);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CChildFrame diagnostics
-
- #ifdef _DEBUG
- void CChildFrame::AssertValid() const
- {
- CMDIChildWnd::AssertValid();
- }
-
- void CChildFrame::Dump(CDumpContext& dc) const
- {
- CMDIChildWnd::Dump(dc);
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CChildFrame message handlers
- void CChildFrame::OnColors(UINT nID)
- {
- CMDI2ViewsBDoc* pDoc;
- pDoc = (CMDI2ViewsBDoc*)GetActiveDocument();
-
- pDoc->SetColor(IDtoColorRef(nID));
- pDoc->UpdateAllViews(NULL);
- }
-
- void CChildFrame::OnUpdateColors(CCmdUI* pCmdUI)
- {
- CMDI2ViewsBDoc* pDoc;
- pDoc = (CMDI2ViewsBDoc*)GetActiveDocument();
-
- pCmdUI->SetCheck(pDoc->GetColor() == IDtoColorRef(pCmdUI->m_nID));
- }
-
- // This function converts one of the 4 Command IDs to a COLORREF value.
- COLORREF CChildFrame::IDtoColorRef(int nID)
- {
- switch (nID)
- {
- case ID_COLORS_RED:
- return RED;
- case ID_COLORS_GREEN:
- return GREEN;
- case ID_COLORS_BLUE:
- return BLUE;
- default:
- return BLACK;
- }
- }
-