Chapter 5: The Document/View Architecture Visual C++ and MFC Fundamentals
CFrameWnd::OnActivate(nState, pWndOther, bMinimized);
// TODO: Add your message handler code here
switch( nState )
{
case WA_ACTIVE:
MessageBox("This window has been activated, without the mouse!");
break;
case WA_INACTIVE:
MessageBox("This window has been deactivated and cannot be
changed now!!");
break;
case WA_CLICKACTIVE:
MessageBox("This window has been activated using the mouse!!!");
break;
}
}
void CMainFrame::OnPaint()
{
CFrameWnd::OnPaint();
MessageBox("The window has been painted<==>");
}
BOOL CExerciseApp::InitInstance()
{
m_pMainWnd = new CMainFrame ;
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
CExerciseApp theApp;
- Test the application and return to MSVC
4.2.5 Window Sizing.....................................................................................
WM_SIZE: When using an application, one of the actions a user can perform on a
window is to change its size, provided the window allows this. Also, some time to time, if
the window allows it, the user can minimize, maximize, or restore a window. Whenever
any of these actions occur, the operating system must keep track of the size of a window.
When the size of a window has changed, the window sends the ON_WM_SIZE message.
Its syntax is:
afx_msg void OnSize(UINT nType, int cx, int cy);
The nType argument specifies what type of action to take. It can have one of the
following values:
Value Description
SIZE_MINIMIZED The window has been minimized
SIZE_MAXIMIZED The window has been maximized
SIZE_RESTORED The window has been restored from being maximized or