|
// MainWindow.hµ¿¾È
// base class¿¡CMessageFilter¸¦
Ãß°¡
class CMyWindow : public CWindowImpl<CMyWindow>, public CMessageFilter
{
public:
// À©µµ¿ì
Ŭ·¡½º¸íÀ» µî·Ï
DECLARE_WND_CLASS(_T("Hello"));
private:
// ¸Þ¼¼Áö ÇÊÅÍ Ã³¸®
virtual BOOL PreTranslateMessage(MSG*
pMsg){
return FALSE;
}
// ¸Þ¼¼Áö ¸Ê
BEGIN_MSG_MAP_EX(CMyWindow)
MSG_WM_PAINT(OnPaint)
MSG_WM_CREATE(OnCreate)
MSG_WM_DESTROY(OnDestroy)
END_MSG_MAP()
void OnPaint(HDC /*hDC*/){
PAINTSTRUCT ps;
HDC hDC = BeginPaint(&ps);
RECT rect;
GetClientRect(&rect);
DrawText(hDC, _T("Hello,
ATL/WTL"),
-1, &rect, DT_SINGLELINE | DT_CENTER |
DT_VCENTER);
EndPaint(&ps);
}
LRESULT OnCreate(LPCREATESTRUCT lpcs){
// ¸Þ½ÃÁö ·çÇÁ¿¡ ¸Þ¼¼Áö ÇÊÅ͸¦ Ãß°¡
CMessageLoop* pLoop = _Module.GetMessageLoop();
pLoop->AddMessageFilter(this);
return 0;
}
void OnDestroy(){
PostQuitMessage(0);
}
};
|