|
呜呜,开始学习vc就受到打击,我在VC下编了一个win32 Application,运行后不能响应鼠标左右键,代码如下:
#include <afxwin.h>
class CMyApp:public CWinApp
{
public:
virtual BOOL InitInstance();
};
class CMainWnd:public CFrameWnd
{
protected:
afx_msg void OnLButtonDown(UINT nFlags,CPoint point);
afx_msg void OnRButtonDown(UINT nFlags,CPoint point);
public:
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CMainWnd,CFrameWnd)
ON_WM_RBUTTONDOWN()
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
void CMainWnd::OnLButtonDown(UINT nFlags,CPoint point)
{
// MessageBox("左键单击");
CDC *pDC=GetDC();
pDC->TextOut(point.x,point.y,"hello",5);
CFrameWnd::OnLButtonDown(nFlags,point);
}
void CMainWnd::OnRButtonDown(UINT nFlags,CPoint point)
{
MessageBox("右键单击");
CFrameWnd::OnRButtonDown(nFlags,point);
}
BOOL CMyApp::InitInstance()
{
CFrameWnd* p=new CFrameWnd;
p->Create(0,"yang");
p->ShowWindow(SW_SHOWDEFAULT);
p->UpdateWindow();
// AfxGetApp()->m_pMainWnd=p;
this->m_pMainWnd=p;
return TRUE;
}
CMyApp myapp; |
|