inputview.cpp

来自「用VC编写的程序」· C++ 代码 · 共 103 行

CPP
103
字号
// InputView.cpp : implementation file
//

#include "stdafx.h"
#include "MultiView.h"
#include "InputView.h"
#include "MultiViewDoc.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CInputView

IMPLEMENT_DYNCREATE(CInputView, CFormView)

CInputView::CInputView()
	: CFormView(CInputView::IDD)
{
	//{{AFX_DATA_INIT(CInputView)
	m_nB = 0;
	m_nG = 0;
	m_nR = 0;
	//}}AFX_DATA_INIT
}

CInputView::~CInputView()
{
}

void CInputView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CInputView)
	DDX_Text(pDX, IDC_EDIT1, m_nB);
	DDV_MinMaxUInt(pDX, m_nB, 0, 255);
	DDX_Text(pDX, IDC_EDIT2, m_nG);
	DDV_MinMaxUInt(pDX, m_nG, 0, 255);
	DDX_Text(pDX, IDC_EDIT3, m_nR);
	DDV_MinMaxUInt(pDX, m_nR, 0, 255);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CInputView, CFormView)
	//{{AFX_MSG_MAP(CInputView)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CInputView diagnostics

#ifdef _DEBUG
void CInputView::AssertValid() const
{
	CFormView::AssertValid();
}

void CInputView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CInputView message handlers

void CInputView::OnButton1() 
{
	// TODO: Add your control notification handler code here
	CMultiViewDoc* pDoc=GetDocument();
	ASSERT_VALID(pDoc);
	UpdateData();
	pDoc->m_cRectangle=RGB(m_nR,m_nG,m_nB);
	pDoc->SetModifiedFlag();
	pDoc->UpdateAllViews(this);
	
}

CMultiViewDoc* CInputView::GetDocument()
{
   ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMultiViewDoc)));
   return (CMultiViewDoc*)m_pDocument;
}

void CInputView::OnInitialUpdate() 
{
	CFormView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class
	CMultiViewDoc* pDoc=GetDocument();
	ASSERT_VALID(pDoc);
	m_nR=GetRValue(pDoc->m_cRectangle);
	m_nG=GetGValue(pDoc->m_cRectangle);
	m_nB=GetBValue(pDoc->m_cRectangle);
	UpdateData(FALSE);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?