⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defmsgview.cpp

📁 defmsg(自定义消息举例code
💻 CPP
字号:
// defmsgView.cpp : implementation of the CDefmsgView class
//

#include "stdafx.h"
#include "defmsg.h"

#include "defmsgDoc.h"
#include "defmsgView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDefmsgView

IMPLEMENT_DYNCREATE(CDefmsgView, CView)

BEGIN_MESSAGE_MAP(CDefmsgView, CView)
	//{{AFX_MSG_MAP(CDefmsgView)
	ON_WM_LBUTTONDOWN()
	ON_MESSAGE(WM_MY_MESSAGE, OnMyMessage)
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CDefmsgView construction/destruction

CDefmsgView::CDefmsgView()
{
	// TODO: add construction code here

}

CDefmsgView::~CDefmsgView()
{
}

BOOL CDefmsgView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CDefmsgView drawing

void CDefmsgView::OnDraw(CDC* pDC)
{
	CDefmsgDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CDefmsgView printing

BOOL CDefmsgView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CDefmsgView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CDefmsgView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}


/////////////////////////////////////////////////////////////////////////////
// CDefmsgView diagnostics

#ifdef _DEBUG
void CDefmsgView::AssertValid() const
{
	CView::AssertValid();
}

void CDefmsgView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CDefmsgDoc* CDefmsgView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDefmsgDoc)));
	return (CDefmsgDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CDefmsgView message handlers

void CDefmsgView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
//	MessageBox("hello");
    this->SendMessage(WM_MY_MESSAGE);
	CView::OnLButtonDown(nFlags, point);
}

LRESULT CDefmsgView::OnMyMessage(WPARAM wParam,LPARAM lParam)
{ 
CClientDC dc(this);
dc.TextOut(200,200,"测试自定义消息成功啦^_^");
return 1;
} 

⌨️ 快捷键说明

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