This tip comes from a post in comp.os.ms-windows.programmer.tools.mfc...
Hello,
I'm new to MFC/Windows, done a fair amount of reading, but...
How does one insert anything into a list box (that is in a CDialog
window) if the list box is created with the resource editor (with the
control toolbox window with the combo box. list box, buttons, etc...)?
Where is the handle to the CLisBox object? Any help appreciated.
Thanks,
-- Mark Crosland
When you create a control with the resource editor, you or the IDE
assign an ID to the control (IDC_LIST1). GetDlgItem(IDC_LIST1)
returns a CWnd * to the object which you can cast to a CListBox*:
CListBox *pListBox = (CListBox *) GetDlgItem(IDC_LIST1);
--OR--
You can use the ClassWizard to create a class member that corresponds
to the listbox. Select the "member variables" tab from ClassWizard select the listbox
id from the list and press the "add variable" button. Specify a member name and
select "control" from the category combobox.
-- Rick Murtagh