filling in list boxes

This is a discussion on filling in list boxes within the Windows Programming forums, part of the Platform Specific Boards category; I have a couple list boxes in my user setup dialog box. I want to fill those with possible options. ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    26

    filling in list boxes

    I have a couple list boxes in my user setup dialog box. I want to fill those with possible options. acorrding to my book I do that by sending a LB_ADDSTRING to the listbox child window control. I am trying to do that in the Dialog proccedure as shown here:
    Code:
    LRESULT CALLBACK NewUser(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	switch (message)
    	{
    		case WM_INITDIALOG:
    			SendDlgItemMessage(hDlg, IDC_Experienc, LB_ADDSTRING, 0 ,(LPARAM) TEXT("Beginner"));
    			SendDlgItemMessage(hDlg, IDC_Experience, LB_ADDSTRING, 0 ,(LPARAM) TEXT("Intermediate"));
    			SendDlgItemMessage(hDlg, IDC_Experience, LB_ADDSTRING, 0 ,(LPARAM) TEXT("Advanced"));
    			SendDlgItemMessage(hDlg, IDC_Experience, LB_ADDSTRING, 0 ,(LPARAM) TEXT("Guru"));
    			SendDlgItemMessage(hDlg, IDC_NumbDrugs, LB_ADDSTRING, 0, (LPARAM) TEXT("One"));
    			SendDlgItemMessage(hDlg, IDC_NumbDrugs, LB_ADDSTRING, 0, (LPARAM) TEXT("Two"));
    			SendDlgItemMessage(hDlg, IDC_NumbDrugs, LB_ADDSTRING, 0, (LPARAM) TEXT("Three"));
    
    			return TRUE;
    
    		case WM_COMMAND:
    			if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 
    			{
    				EndDialog(hDlg, LOWORD(wParam));
    				return TRUE;
    			}
    			break;
    	}
        return FALSE;
    }
    Here is my Dialog setup if that matters:
    Code:
    IDD_NEWUSER DIALOGEX 0, 0, 259, 138
    STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
    CAPTION "New User"
    FONT 8, "MS Sans Serif", 0, 0, 0x0
    BEGIN
        DEFPUSHBUTTON   "OK",IDOK,71,106,50,14
        PUSHBUTTON      "Cancel",IDCANCEL,167,106,50,14
        CTEXT           "New User Setup",IDC_STATIC,83,7,92,16,SS_CENTERIMAGE
        LTEXT           "User Name:",IDC_STATIC,15,26,38,8
        EDITTEXT        IDC_Name,68,22,124,14,ES_AUTOHSCROLL
        LTEXT           "User Weight",IDC_STATIC,15,46,40,8
        EDITTEXT        IDC_Weight,68,41,40,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
        LTEXT           "Experience",IDC_STATIC,15,66,36,8
        COMBOBOX        IDC_Experience,68,63,48,30,CBS_DROPDOWNLIST | CBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
        LTEXT           "Number of",IDC_STATIC,15,83,34,8
        LTEXT           "Drugs",IDC_STATIC,22,92,20,8
        COMBOBOX        IDC_NumbDrugs,68,86,48,30,CBS_DROPDOWNLIST | CBS_SORT | CBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
    END
    Any idea on the list boxes are still empty? Thanks for the help?

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    According to your dialog definition you are using combo-boxes, so try using CB_ADDSTRING rather than LB_ADDSTRING.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sorting linked list please help with CODE
    By scarlet00014 in forum C Programming
    Replies: 3
    Last Post: 09-27-2008, 11:24 PM
  2. Duplicating value of pointer to linked list
    By zephyrcat in forum C Programming
    Replies: 14
    Last Post: 01-22-2008, 02:19 PM
  3. singly linked circular list
    By DarkDot in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2007, 08:55 PM
  4. Linked list with two class types within template.
    By SilasP in forum C++ Programming
    Replies: 3
    Last Post: 02-09-2002, 05:13 AM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21