Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

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


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:
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;
}
}


BOOL CExerciseApp::InitInstance()
{
m_pMainWnd = new CMainFrame ;
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();


return TRUE;
}


CExerciseApp theApp;



  1. Test the application. While it is displaying, open Notepad

  2. Display each window using the mouse. Then activate your window using Alt+Tab

Free download pdf