Results 1 to 2 of 2

Thread: Need Help!!!(Visual C++)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Posts
    28

    Need Help!!!(Visual C++)

    I want to change the list content in the combo box after I click a button.....I only know that add a variable to the combo box.....and then change that content.......but i want to add serveral data into it.......anyone can help me????????
    Thanks alot

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Just keep sending the CB_ADDSTRING message like you did to add the first item:
    CB_ADDSTRING
    An application sends a CB_ADDSTRING message to add a string to the list box of a combo box. If the combo box does not have the CBS_SORT style, the string is added to the end of the list. Otherwise, the string is inserted into the list, and the list is sorted.

    To send this message, call the SendMessage function with the following parameters.

    SendMessage(
    (HWND) hWnd, // handle to destination window
    CB_ADDSTRING, // message to send
    (WPARAM) wParam, // not used; must be zero
    (LPARAM) lParam // string to add (LPCTSTR)
    );
    Parameters
    wParam
    This parameter is not used.
    lParam
    Pointer to the null-terminated string to be added. If you create the combo box with an owner-drawn style but without the CBS_HASSTRINGS style, the value of the lParam parameter is stored as item data rather than the string it would otherwise point to. The item data can be retrieved or modified by sending the CB_GETITEMDATA or CB_SETITEMDATA message.
    Return Values
    The return value is the zero-based index to the string in the list box of the combo box. If an error occurs, the return value is CB_ERR. If insufficient space is available to store the new string, it is CB_ERRSPACE.

    Remarks
    If you create an owner-drawn combo box with the CBS_SORT style but without the CBS_HASSTRINGS style, the WM_COMPAREITEM message is sent one or more times to the owner of the combo box so the new item can be properly placed in the list.

    To insert a string at a specific location within the list, use the CB_INSERTSTRING message.

    If the combo box has WS_HSCROLL style and you add a string wider than the combo box, send a LB_SETHORIZONTALEXTENT message to ensure the horizontal scrollbar appears.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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