Visual C++ and MFC Fundamentals Chapter 5: The Document/View Architecture
afx_msg void OnPaint()
Practical Learning: Using the Paint Message
- To use the structure of the WM_PAINT message, change the program as follows:
#include <afxwin.h>
class CMainFrame : public CFrameWnd
{
public:
CMainFrame ();
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};
CMainFrame::CMainFrame()
{
// Create the window's frame
Create(NULL, "Windows Application", WS_OVERLAPPEDWINDOW,
CRect(120, 100, 700, 480), NULL);
}
class CExerciseApp: public CWinApp
{
public:
BOOL InitInstance();
};
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_WM_CREATE()
ON_WM_SHOWWINDOW()
ON_WM_ACTIVATE()
ON_WM_PAINT()
END_MESSAGE_MAP()
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
void CMainFrame::OnShowWindow(BOOL bShow, UINT nStatus)
{
CFrameWnd::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
//ShowWindow(SW_SHOW);
}
void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{