Thread: Problem with Combo Box

  1. #1
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256

    Problem with Combo Box

    Can't get a combo box to display its content. If I query for its content, it seems to be working fine. CB_GETCOUNT returns the correct number, for example. I'm not sure what to make of it...

    Code:
    DLG_MASTERCONFIGURE DIALOG 0, 0, 260, 140
    .....
       BEGIN
          .....
          COMBOBOX                               IDCMB_SCREENNUM,   18, 88,  35,  13, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL
          .....
       END
    Code:
        case WM_INITDIALOG:
         {
          int si;
          char ScreenNum[3];
          for(si = 1; si <= NumberOfScreens; ++si)
           {
            snprintf(ScreenNum, 3, "%i", si);
            SendDlgItemMessage(hDlg, IDCMB_SCREENNUM, CB_ADDSTRING, 0, (LPARAM)ScreenNum);
           }
         }
        break;
    Code:
    void function(void)
     {
      function();
     }

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    291
    Because the combobox is too small (the height). Try to change to:

    Code:
    COMBOBOX IDCMB_SCREENNUM,18,88,35,100,CBS_DROPDOWNLIST|CBS_SORT|WS_VSCROLL
    Now it will expand the list since 100px height, and if there's more items it will also show a vertical scroll bar.

    Hope that helps
    Niara

  3. #3
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    291
    Ah, you can also set the first item selected using:

    Code:
    SendDlgItemMessage(hwnd,IDCMB_SCREENNUM,CB_SETCURSEL,(WPARAM)0,0);
    Niara

  4. #4
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    The height corresponds to the list portion? That's annoying. Thanks for the tip.
    Code:
    void function(void)
     {
      function();
     }

  5. #5
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    291
    Yes, the height in that case it corresponds to the max height that the expanded list can have. So if you set a height of 100px and 3 items to show each of 25px, it will show a list of 3*25px, but if you have 5 items it will show a list of 100px with a vertical scroll (if you have defined that the control can have a vscroll, of course). Or that's how I understand that, if it's wrong please correct

    Niara

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. Getting index of chosen item in the combo box
    By what3v3r in forum Windows Programming
    Replies: 4
    Last Post: 09-01-2006, 11:49 AM
  3. I can't init that combo box!
    By Gravedigga in forum Windows Programming
    Replies: 10
    Last Post: 10-06-2003, 04:44 AM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. Ihave a problem with an EDIT box..
    By SyntaxBubble in forum Windows Programming
    Replies: 1
    Last Post: 10-30-2001, 09:25 AM