messageview.cpp

来自「一个有分割窗口的程序」· C++ 代码 · 共 92 行

CPP
92
字号
// messageView.cpp : implementation file
//

#include "stdafx.h"
#include "testCard.h"
#include "messageView.h"

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

/////////////////////////////////////////////////////////////////////////////
// messageView

IMPLEMENT_DYNCREATE(messageView, CFormView)

messageView::messageView()
	: CFormView(messageView::IDD)
{
	//{{AFX_DATA_INIT(messageView)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_editBrush.CreateSolidBrush(RGB(255, 255, 255));
}

messageView::~messageView()
{
}

void messageView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(messageView)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(messageView, CFormView)
	//{{AFX_MSG_MAP(messageView)
	ON_WM_SIZE()
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// messageView diagnostics

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

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

/////////////////////////////////////////////////////////////////////////////
// messageView message handlers

void messageView::OnSize(UINT nType, int cx, int cy) 
{
	this->ShowWindow(SW_MAXIMIZE);
	
	CWnd *pchild = this->GetWindow(GW_CHILD);//只有一个顶层子窗口
	if(pchild != NULL){
		CRect rect;
		this->GetWindowRect(&rect);
		pchild->ScreenToClient(&rect);
		pchild->SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(),
							SWP_NOZORDER | SWP_NOACTIVATE);
	}	
}

HBRUSH messageView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
	
	if(pWnd->GetDlgCtrlID() == IDC_EDIT1){
		pDC->SetBkColor(RGB(255, 255, 255));
		return m_editBrush;	
	}
	
	// TODO: Return a different brush if the default is not desired
	return hbr;
}

⌨️ 快捷键说明

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