ComboBox series API functions

Source: Internet
Author: User

1. Add

Int
Combobox_addstring (

Hwnd hwndctl, // window handle

Lpctstr lpsz // content to be added

);

The difference between the two lies in the second parameter: one can add content to the specified position, and the other cannot.

 

2. Determine the index of the current option:

Int combobox_getcursel (
Hwnd hwndctl // the unique parameter is the control handle, and the return value is the index number of the string displayed on the handle ';

);

The return value of cur: currentsel: selection is the number of the current item, starting from 0.
What we get is not a string like "Beijing", but an index (number). If no project is selected, the iindex value returned from the function is cb_err. Make an example

3. delete items:
Int combobox_deletestring (
Hwnd hwndctl, // control handle,

Int index // the index number you want to delete (a bit like the number of braces in the array, also starting from scratch ),

);

The return value is the number of strings left after deletion;

4. Obtain the value of an item.

Int getlbtext (
Int nindex, // contains the index of the string starting from scratch in the list box to be copied.
Lptstr lpsztext // point to the buffer that receives the string. The buffer must have enough space for this string and a null character to terminate.
) Const;
Void getlbtext (
Int nindex,
Cstring & rstring // rstring pairCstring.
) Const;

Return Value: a string of length (in bytes), excluding the end null character. If nindex does not specify a valid index, the returned value isCb_err.


Note: The second form of the member function contains the text of the Project loaded by CstringObject.
Example:
Cstring str1, str2;
Int N;
For (INT I = 0; I <m_pcombobox-> getcount (); I ++)
{
N = m_pcombobox-> getlbtextlen (I );
M_pcombobox-> getlbtext (I, str1.getbuffer (n ));
Str1.releasebuffer ();

Str2.format (_ T ("item % d: % s \ r \ n"), I, str1.getbuffer (0 ));
Afxdump (str2 );
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.