Thread: Initializing Combo Box

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    87

    Initializing Combo Box

    Hi and thanks for reading this.

    I want to initialize a combo box.When I create the dialog, in which the box will be, I send CB_ADDSTRING to the box, but it doesn't works

    Here is the code:

    theWnd=CreateDialog(hInst,MAKEINTRESOURCE(IDD_PROB A),NULL,DlgProc);
    i=GetLastError();
    SendDlgItemMessage(theWnd,IDC_COMBO1,CB_ADDSTRING, 0,(LPARAM) "some text");
    ShowWindow(theWnd, SW_SHOW);

    If you can, please tell me why

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Try sending the CB_ADDSTRING message within a WM_INITDIALOG message handler.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Posts
    219
    I believe you should do the following...
    Code:
    ...
    case WM_INITDIALOG:
        HWND hCB = GetDlgItem(hDlg, IDC_COMBO1); // Get HWND of Combo Box, hDlg is handle sent to DLGPROC
        SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)"Some Text");
        break;
    ....
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Create new combo boxes based on items selected in preview combo box
    By RealityFusion in forum Windows Programming
    Replies: 2
    Last Post: 01-10-2007, 09:50 AM
  2. No data showing in combo box
    By PJYelton in forum Windows Programming
    Replies: 6
    Last Post: 04-29-2005, 07:20 PM
  3. How to program a "back" button with MFC
    By 99atlantic in forum Windows Programming
    Replies: 3
    Last Post: 04-26-2005, 08:34 PM
  4. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM
  5. SkyLock tech demo (GUI - DX combo box)
    By jdinger in forum Game Programming
    Replies: 4
    Last Post: 07-14-2002, 09:04 PM