Oikeasti viestin käsittelijöiden eteen laitetaan afx_msg
class CMainWindow : public CFrameWnd {
public:
CMainWindow() { Create(NULL,"Hello World!"); }
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};mutta
koska afx_msg on määritelty tyhjäksi, ei
tätä käytetä jatkoesimerkeissä jotta esimerkit
olisivat enemmän OWL - esimerkkien näköisiä.
// hello2.cpp
#include <afxwin.h>
class CMainWindow : public CFrameWnd {
public:
CMainWindow() { Create(NULL,"Hello World!"); }
void OnPaint() {
CPaintDC dc(this);
dc.TextOut(10,10,"Hello world!");
}
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP( CMainWindow, CFrameWnd )
ON_WM_PAINT()
END_MESSAGE_MAP()
class CHelloApp : public CWinApp {
public:
virtual BOOL InitInstance() {
m_pMainWnd = new CMainWindow();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}
};
CHelloApp HelloApp; // HelloApp's constructor initializes and runs the app