Droopy2
May 25th, 1999, 06:22 AM
I use a SDI Interface and i launch a DialogBox who contain a combobox,
before XXXX.DoModal(); I want to AddString or InsertString in the combobox but Visual c++ 6.0 d'ont want to execute this code.
Can you help me.
BrianOG
May 25th, 1999, 07:02 AM
You cant add strings to the combo-box before DoModal() because the combo box hasnt been created.
During the DoModal process, OnInitDialog (WM_INITDIALOG) is called (before the dlg is shown) and here you can add the strings to the combobox.
If what you are trying to do is something like a results list (i.e. you are doing some processing and adding strings to the list, then when you finish processing display the dlg) there are a few other options available to you.
1. In your application, create a CStringList, add the strings to this, and then pass the string list to the dlg before DoModal, and in OnInitDialog, iterate through the list and add the strings to the combo-box
2. Add a function to the dlg class to take the strings, which it then holds internally, and uses to populate the dlg during OnInitDialog.
ric
May 25th, 1999, 07:03 AM
You should override your Dialog InitDialog() function like this:
BOOL CMyDialog::InitDialog()
{
CDialog::InitDialog();
(CComboBox*)GetDlgItem(IDC_COMBO1)->AddString("String1");
return TRUE;
}