combobox in c

This is a discussion on combobox in c within the Windows Programming forums, part of the Platform Specific Boards category; hi all, I need help Please I create a Combobox in win32 from c and i should read frot the ...

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    2

    combobox in c

    hi all,

    I need help Please
    I create a Combobox in win32 from c
    and i should read frot the combobox and insert to pointr or array.

    how i can ???

    I create the combobox so :

    hwndCombobox = CreateWindow (TEXT("combobox"),
    WS_CHILD | WS_VISIBLE |,
    cxChar+ 20, 80,
    4 * cxChar, 7 * cyChar / 4,
    hwnd, (HMENU) (EDITID+1),
    ((LPCREATESTRUCT) lParam) -> hInstance, NULL) ;


    I hope I explained myself properly


    Thank helpers
    Last edited by kaliberon; 12-20-2011 at 08:20 AM.

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    287
    You can use the message CB_GETLBTEXT to get the text from a combobox; see the message description:

    Code:
    CB_GETLBTEXT  
    wParam = (WPARAM) index;                // item index 
    lParam = (LPARAM) (LPCSTR) lpszBuffer;  // address of buffer
    The buffer is a pointer to a buffer that receives the text (should have enought space also for the terminating null character). So if you want to get the combobox item into a pointer you should allocate space for the text and get it using that message. If you don't know how length is the text, you can also use the message CB_GETLBTEXTLEN, see the description:

    Code:
    CB_GETLBTEXTLEN  
    wParam = (WPARAM) index;  // item index 
    lParam = 0;               // not used; must be zero

    So get the length of the item-text, allocate a buffer for it (remember to allocate an extra byte for the terminating character) and get it; now you can keep it as a single pointer or just send it to an array.

    Hope that helps
    Niara

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    211
    Win32 Tutorials - Combo Boxes

    This is a good tutorial site for that.

    Did you create it in the .rc (Resource file)?

  4. #4
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    287
    Quote Originally Posted by binks View Post
    Did you create it in the .rc (Resource file)?
    You cannot call 'CreateWindow()' from a resource file, take a look at the kaliberon posted code
    The creation mode is not relevant when the point is how to read the content (in that case)

    Regards
    Niara

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    211
    I was refering to this
    Code:
    #include "resource.h"
    
    IDD_CONTROLSDLG DIALOG 260, 200, 180, 120
    STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
    CAPTION "Windows Controls"
    FONT 8, "MS Shell Dlg"
    BEGIN
        DEFPUSHBUTTON   "Close", IDCANCEL, 120, 100, 50, 14
        COMBOBOX        IDD_SIZE_CBO, 40, 8, 90, 80END

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Combobox in c
    By kaliberon in forum C Programming
    Replies: 2
    Last Post: 12-20-2011, 10:41 AM
  2. ComboBox Help
    By Jesse20ghet in forum C# Programming
    Replies: 3
    Last Post: 05-24-2011, 05:50 AM
  3. How to use ComboBox's
    By bikr692002 in forum C++ Programming
    Replies: 2
    Last Post: 04-08-2006, 09:09 PM
  4. Combobox help
    By Dohojar in forum Windows Programming
    Replies: 5
    Last Post: 04-15-2003, 07:02 AM
  5. Add String To Combobox?
    By (TNT) in forum Windows Programming
    Replies: 1
    Last Post: 09-15-2001, 04:40 AM

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