|
// MainWindow.h³»
class CMyWindow : public CWindowImpl<CMyWindow>,
public CMessageFilter,
public CIdleHandler
{
public:
// À©µµ¿ì
Ŭ·¡½º¸í , µµ±¸¸ðÀ½À» µî·Ï
static CWndClassInfo&
GetWndClassInfo()
{
static CWndClassInfo wc =
{
{sizeof(WNDCLASSEX), CS_HREDRAW |
CS_VREDRAW, StartWindowProc,
0, 0, NULL, NULL, NULL, (HBRUSH)(COLOR_WINDOW + 1),
MAKEINTRESOURCE(IDR_MENU_MAIN),
// µµ±¸¸ðÀ½
"Hello", NULL},
NULL, NULL, IDC_ARROW, TRUE, 0, _T("")
};
return wc;
}
private:
// ¸Þ¼¼Áö ÇÊÅÍ Ã³¸®
virtual BOOL PreTranslateMessage(MSG*
pMsg){
return FALSE;
}
// ¾ÆÀ̵¹ ó¸®
virtual BOOL OnIdle(){
return FALSE;
}
// ¸Þ¼¼Áö ¸Ê
BEGIN_MSG_MAP_EX(CMyWindow)
MSG_WM_PAINT(OnPaint)
MSG_WM_CREATE(OnCreate)
MSG_WM_DESTROY(OnDestroy)
COMMAND_ID_HANDLER_EX(ID_MENUITEM_EXIT,
OnMenuExit)
END_MSG_MAP()
void OnPaint(HDC /*hDC*/){
CPaintDC dc(m_hWnd);
CRect rect;
GetClientRect(rect);
dc.DrawText(_T("Hello, ATL/WTL"), -1,
rect, DT_SINGLELINE | DT_CENTER |
DT_VCENTER);
}
LRESULT OnCreate(LPCREATESTRUCT lpcs){
// ¸Þ½ÃÁö ·çÇÁ¿¡ ¸Þ¼¼Áö ÇÊÅÍ¿Í ¾ÆÀ̵¹
Çڵ鷯¸¦ Ãß°¡
CMessageLoop* pLoop = _Module.GetMessageLoop();
pLoop->AddMessageFilter(this);
pLoop->AddIdleHandler(this);
return 0;
}
void OnDestroy(){
PostQuitMessage(0);
}
void OnMenuExit(UINT
uNotifyCode, int nID, HWND hWndCtl){
PostMessage(WM_CLOSE);
}
};
|