Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 20: List-Based Controls



  1. Right-click the new menu item and click Add Event Handler...

  2. Accept the Message Type as COMMAND. In the Class List, click CAirCraft1View.
    Accept the name of the function. Then click Add And Edit and implement the event
    as follows:


void CAirCraft1View::OnViewAh64()
{
// TODO: Add your command handler code here
nImage = 0;
Invalidate();
}


  1. Again, under the View menu, create a new menu item with a caption as
    A&H64 Side and press Enter

  2. Add a COMMAND Event Handler for the new menu item. Associate it with the
    view class and implement it as follows:


void CAirCraft1View::OnViewAh64side()
{
// TODO: Add your command handler code here
nImage = 1;
Invalidate();
}


  1. Again, under the View menu, create a new menu item with a caption as A&kiowa
    and press Enter

  2. Add a COMMAND Event Handler for the new menu item. Associate it with the
    view class and implement it as follows:


void CAirCraft1View::OnViewAkiowa()
{
// TODO: Add your command handler code here
nImage = 2;
Invalidate();
}


  1. Again, under the View menu, create a new menu item with a caption as
    &Commanche and press Enter

  2. Add a COMMAND Event Handler for the new menu item. Associate it with the
    view class and implement it as follows:


void CAirCraft1View::OnViewCommanche()
{
// TODO: Add your command handler code here
nImage = 3;
Invalidate();
}


  1. Test the application

Free download pdf