Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 17: Track-Based Controls


Car[4].CarPicture = IDB_MARQUIS;

Car[5].Make = "Mercury";
Car[5].Model = "Mystique";
Car[5].CarYear = 2000;
Car[5].Doors = 4;
Car[5].CarPicture = IDB_MYSTIQUE;

Car[6].Make = "Lincoln";
Car[6].Model = "Navigator";
Car[6].CarYear = 2003;
Car[6].Doors = 5;
Car[6].CarPicture = IDB_NAVIGATOR;

Car[7].Make = "Nissan";
Car[7].Model = "Sentra";
Car[7].CarYear = 1997;
Car[7].Doors = 2;
Car[7].CarPicture = IDB_SENTRA;

Car[8].Make = "Ford";
Car[8].Model = "Focus";
Car[8].CarYear = 2002;
Car[8].Doors = 4;
Car[8].CarPicture = IDB_FOCUS;

Car[9].Make = "Kia";
Car[9].Model = "Sephia";
Car[9].CarYear = 2003;
Car[9].Doors = 4;
Car[9].CarPicture = IDB_SEPHIA;

return TRUE; // return TRUE unless you set the focus to a control
}


  1. To display default values in the dialog box, on top of its OnPaint() event, type the
    following:


void CCarInventory1Dlg::OnPaint()
{
CBitmap Bmp;

Bmp.LoadBitmap(Car[0].CarPicture);

m_Make.Format("%s", Car[0].Make);
m_Model.Format("%s", Car[0].Model);
m_Year.Format("%d", Car[0].CarYear);
m_Doors.Format("%d", Car[0].Doors);
m_Picture.SetBitmap(Bmp);
UpdateData(FALSE);

if (IsIconic())
{

...
}
}
21. Test the application:

Free download pdf