Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

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


enum { IDD = IDD_CARINVENTORY1_DIALOG };

protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support

// Implementation
protected:
HICON m_hIcon;

// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()

private:
CListOfCars Car[10];
};


  1. To initialize the array, type the following in the OnInitDialog event:


BOOL CCarInventory1Dlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here
Car[0].Make = "Honda";
Car[0].Model = "Civic";
Car[0].CarYear = 1998;
Car[0].Doors = 4;
Car[0].CarPicture = IDB_CIVIC;

Car[1].Make = "Hyundai";
Car[1].Model = "Elantra";
Car[1].CarYear = 1996;
Car[1].Doors = 4;
Car[1].CarPicture = IDB_ELANTRA;

Car[2].Make = "Ford";
Car[2].Model = "Escape";
Car[2].CarYear = 2003;
Car[2].Doors = 5;
Car[2].CarPicture = IDB_ESCAPE;

Car[3].Make = "Ford";
Car[3].Model = "Escort";
Car[3].CarYear = 1997;
Car[3].Doors = 2;
Car[3].CarPicture = IDB_ESCORT;

Car[4].Make = "Mercury";
Car[4].Model = "Grand Marquis";
Car[4].CarYear = 2001;
Car[4].Doors = 4;
Free download pdf