|
// mainfrm.h
class CMainFrame : public CFrameWindowImpl<CMainFrame>,
public CUpdateUI<CMainFrame>, public CMessageFilter,
public CIdleHandler
{
public:
DECLARE_FRAME_WND_CLASS(NULL,
IDR_MAINFRAME)
virtual BOOL PreTranslateMessage(MSG*
pMsg){
return CFrameWindowImpl<CMainFrame>::PreTranslateMessage(pMsg);
}
virtual BOOL OnIdle(){
UIUpdateStatusBar();
return FALSE;
}
BEGIN_UPDATE_UI_MAP(CMainFrame)
// ¿£Æ®¸® ¾øÀ½
END_UPDATE_UI_MAP()
BEGIN_MSG_MAP_EX(CMainFrame)
MSG_WM_MOUSEMOVE(OnMouseMove)
MSG_WM_SIZE(OnSize)
MSG_WM_CREATE(OnCreate)
COMMAND_ID_HANDLER_EX(ID_APP_EXIT, OnMenuExit)
CHAIN_MSG_MAP(CUpdateUI<CMainFrame>)
CHAIN_MSG_MAP(CFrameWindowImpl<CMainFrame>)
END_MSG_MAP()
LRESULT OnCreate(LPCREATESTRUCT lpcs){
// »óÅ ¹Ù¸¦ ÀÛ¼º
CreateSimpleStatusBar();
UIAddStatusBar(m_hWndStatusBar);
// ¸Þ½ÃÁö ·çÇÁ¿¡ ¸Þ¼¼Áö
ÇÊÅÍ¿Í ¾ÆÀ̵¹ Çڵ鷯¸¦ Ãß°¡
CMessageLoop* pLoop = _Module.GetMessageLoop();
pLoop->AddMessageFilter(this);
pLoop->AddIdleHandler(this);
return 0;
}
void OnSize(UINT uType, CSize size){
// ¸¶¿ì½º ÁÂÇ¥¸¦ Ç¥½ÃÇÏ´Â ÆäÀÎÀÇ
Æø
int cxPosPane
= 90;
// µ¥Æ÷¸£Æ®ÆäÀÎÀÇ Æø
CRect rcClient;
GetClientRect(rcClient);
int cxDefaultPane
= rcClient.right - cxPosPane
- ::GetSystemMetrics(SM_CXVSCROLL) - ::GetSystemMetrics(SM_CXEDGE);
// »óÅ ¹Ù¿¡ ÆäÀÎÀ»
¼³Á¤
CStatusBarCtrl bar = m_hWndStatusBar;
int nPanes[] =
{cxDefaultPane, cxDefaultPane
+ cxPosPane};
bar.SetParts(sizeof(nPanes)/sizeof(nPanes[0]),
nPanes);
// base classÀÇWM_SIZE¸Þ¼¼Áö
Çڵ鷯µµ È£ÃâÇϱâ (À§ÇØ)¶§¹®¿¡
SetMsgHandled(false);
}
void OnMouseMove(UINT
uFlags, CPoint ptClient){
CString strPos;
strPos.Format(_T("X:%d, Y:%d"), ptClient.x, ptClient.y);
CStatusBarCtrl bar = m_hWndStatusBar;
bar.SetText(1, strPos);
}
void OnMenuExit(UINT
uNotifyCode, int nID, HWND hWndCtl){
PostMessage(WM_CLOSE);
}
};
|