📄 dialogtest1view.cpp
字号:
// DialogTest1View.cpp : implementation of the CDialogTest1View class
//
#include "stdafx.h"
#include "DialogTest1.h"
#include "DialogTest1Doc.h"
#include "DialogTest1View.h"
#include "DlgModal.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialogTest1View
IMPLEMENT_DYNCREATE(CDialogTest1View, CView)
BEGIN_MESSAGE_MAP(CDialogTest1View, CView)
//{{AFX_MSG_MAP(CDialogTest1View)
ON_COMMAND(ID_MENUITEM_MODAL, OnMenuitemModal)
ON_COMMAND(ID_MENUITEM_NOMODAL, OnMenuitemNomodal)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialogTest1View construction/destruction
CDialogTest1View::CDialogTest1View()
{
// TODO: add construction code here
m_Red = 255;
m_Green = 255;
m_Blue = 255;
this->m_NoModalDlg = NULL;
}
CDialogTest1View::~CDialogTest1View()
{
// delete m_NoModalDlg;
}
BOOL CDialogTest1View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CDialogTest1View drawing
void CDialogTest1View::OnDraw(CDC* pDC)
{
CDialogTest1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CRect rc;
this->GetClientRect(&rc);
CBrush br;
br.CreateSolidBrush(RGB(m_Red,m_Green,m_Blue));
CBrush *oldbr=pDC->SelectObject(&br);
pDC->Rectangle(&rc);
pDC->SelectObject(oldbr);
}
/////////////////////////////////////////////////////////////////////////////
// CDialogTest1View printing
BOOL CDialogTest1View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CDialogTest1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CDialogTest1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CDialogTest1View diagnostics
#ifdef _DEBUG
void CDialogTest1View::AssertValid() const
{
CView::AssertValid();
}
void CDialogTest1View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CDialogTest1Doc* CDialogTest1View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDialogTest1Doc)));
return (CDialogTest1Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDialogTest1View message handlers
void CDialogTest1View::OnMenuitemModal()
{
// TODO: Add your command handler code here
CDlgModal dlg;
dlg.m_Blue = m_Blue;
dlg.m_Red = m_Red;
dlg.m_Green = m_Green;
if(dlg.DoModal() == IDOK){
m_Red = dlg.m_Red;
m_Green = dlg.m_Green;
m_Blue = dlg.m_Blue;
}
this->Invalidate();
}
void CDialogTest1View::setColor(int r, int g, int b)
{
this->m_Red =r;
this->m_Green = g;
this->m_Blue = b;
}
void CDialogTest1View::OnMenuitemNomodal()
{
// TODO: Add your command handler code here
if(this->m_NoModalDlg == NULL){
this->m_NoModalDlg = new CDlgNonModal();
m_NoModalDlg->Create(IDD_DIALOG2,this);
m_NoModalDlg->InitSliders();
m_NoModalDlg->SetView(this);
}
this->m_NoModalDlg->InitColors(m_Red,m_Green,m_Blue);
this->m_NoModalDlg->ShowWindow(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -