|
Hum, I started to suffer from learning vc. I wrote a win32 Application under VC. After running, it can't respond to the left and right mouse buttons. The code is as follows:
#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 ("left-click");
CDC * pDC = GetDC ();
pDC-> TextOut (point.x, point.y, "hello", 5);
CFrameWnd :: OnLButtonDown (nFlags, point);
}
void CMainWnd :: OnRButtonDown (UINT nFlags, CPoint point)
{
MessageBox ("right-click");
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; |
|