Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 5: The Document/View Architecture


{
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();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnMove(int x, int y);
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()
ON_WM_SIZE()
ON_WM_MOVE()
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)
{
CFrameWnd::OnActivate(nState, pWndOther, bMinimized);

// TODO: Add your message handler code here
switch( nState )
{
case WA_ACTIVE:
Free download pdf