2009. 8. 29. 11:40
Programming/MFC
stdafx.h
#define WM_USER_EXAMPLE (WM_USER + 10)
MainFrm.h
protected: afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg LONG OnUserExample(WPARAM wParam, LPARAM lParam); DECLARE_MESSAGE_MAP()
MainFrm.cpp
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) ON_WM_CREATE() ON_COMMAND(ID_MSG_SEND, OnMsgSend) ON_MESSAGE(WM_USER_EXAMPLE, OnUserExample) END_MESSAGE_MAP() void CMainFrame::OnMsgSend() { SendMessage(WM_USER_EXAMPLE, (WPARAM)3.0); } LONG CMainFrame::OnUserExample(WPARAM wParam, LPARAM lParam) { CString strMessage; int nNumber = (int)wParam; strMessage.Format("I received %d", nNumber); AfxMessageBox(strMessage, MB_OK | MB_ICONINFORMATION); return 0; }