CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Posts
    1

    COMBOBOX problems

    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.




  2. #2
    Join Date
    May 1999
    Posts
    116

    Re: COMBOBOX problems

    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.


  3. #3
    Join Date
    Apr 1999
    Posts
    306

    Re: COMBOBOX problems

    You should override your Dialog InitDialog() function like this:

    BOOL CMyDialog::InitDialog()
    {
    CDialog::InitDialog();

    (CComboBox*)GetDlgItem(IDC_COMBO1)->AddString("String1");

    return TRUE;
    }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured