Repository navigation
SysWin Gui Combo
Home › All Categories › sys/win › sys/win/gui › Combo
Adds, finds, selects and reads the items of a combo box, and sets its list and edit box.
A combo box is a list with a selection field above it. With CBS_DROPDOWN the field is an edit
box the user can type into and the list drops down; with CBS_DROPDOWNLIST the field only shows
the selected item; with CBS_SIMPLE the list is always open. Every function here takes the
control's handle first and is written with the namespace: Combo.AddString( hCombo, "Pear" ).
CWindow.AddControl( "ComboBox", ... ) creates a drop-down combo box whose list is sorted
(CBS_DROPDOWN or CBS_SORT); the height you give it is the height with the list dropped down.
Items are numbered from 0. An item has a text and a value of your own (its item data, a
LONG_PTR), which the control stores but never uses. Functions that fail return CB_ERR (-1);
those that add text return CB_ERRSPACE (-2) when memory runs out. The control owns its items
and frees them when they are deleted or the control is destroyed; what an item data value points
to is yours to free.
The cue banner functions need version 6 of the common controls, which a program selects with a
manifest or by calling EnableVisualStyles() before it creates the control. For a combo box with
an image beside each item, see CBEx.
#import "sys/win"
#import "sys/win/gui"
using win, guiA sorted drop-down list of fruit, each item carrying a price in cents. Choosing one puts its text and price in the caption.
#import "sys/win"
#import "sys/win/gui"
using win, gui
const IDC_FRUIT = 101
declare function WndProc( byval hwnd as HWND, byval uMsg as UINT, byval wParam as WPARAM, byval lParam as LPARAM ) as LRESULT
function main() as long
SetProcessDpiAwareness( PROCESS_SYSTEM_DPI_AWARE )
EnableVisualStyles()
dim pWindow as CWindow = "ComboDemo"
dim hWin as HWND = pWindow.Create( NULL, "Combo", @WndProc )
pWindow.SetClientSize( 300, 220 )
pWindow.Center()
dim hCombo as HWND = pWindow.AddControl( "ComboBox", hWin, IDC_FRUIT, "", 10, 10, 280, 200, _
WS_CHILD or WS_VISIBLE or WS_VSCROLL or WS_TABSTOP or CBS_DROPDOWNLIST or CBS_HASSTRINGS or CBS_SORT )
Combo.SetItemData( hCombo, Combo.AddString( hCombo, "Pear" ), 120 )
Combo.SetItemData( hCombo, Combo.AddString( hCombo, "Apple" ), 95 )
Combo.SetItemData( hCombo, Combo.AddString( hCombo, "Banana" ), 40 )
Combo.SetItemData( hCombo, Combo.AddString( hCombo, "Cherry" ), 300 )
Combo.SetCueBannerText( hCombo, "Choose a fruit" )
Combo.SetMinVisible( hCombo, 4 )
return pWindow.DoEvents( SW_NORMAL )
end function
function WndProc( byval hwnd as HWND, byval uMsg as UINT, byval wParam as WPARAM, byval lParam as LPARAM ) as LRESULT
select case uMsg
case WM_COMMAND
if CBCTL( wParam, lParam ) = IDC_FRUIT andalso CBCTLMSG( wParam, lParam ) = CBN_SELCHANGE then
dim hCombo as HWND = cast( HWND, lParam )
SetWindowText( hwnd, Combo.GetLbText( hCombo, -1 ) & ": " & Combo.GetItemData( hCombo, -1 ) & " cents" )
end if
return 0
case WM_DESTROY
PostQuitMessage( 0 )
return 0
end select
return DefWindowProcW( hwnd, uMsg, wParam, lParam )
end function
end main()| Function | Does |
|---|---|
| AddString | Adds an item, in sorted order or at the end. |
| InsertString | Inserts an item at a position. |
| DeleteString | Deletes an item. |
| ResetContent | Deletes every item and clears the edit box. |
| Dir | Adds file, folder and drive names. |
| GetCount | Returns the number of items. |
| GetLbText | Returns the text of an item or of the selected item. |
| GetLbTextLen | Returns the length of an item's text. |
| GetText | Returns the text of the selection field or of an item. |
| GetTextLength | Returns the length of the selection field's or an item's text. |
| SetText | Sets the text of the selection field or replaces an item. |
| ReplaceText | Replaces an item's text. |
| GetItemData | Returns an item's value. |
| SetItemData | Sets an item's value. |
| FindString | Finds an item that begins with a text. |
| FindStringExact | Finds an item whose whole text matches. |
| SelectString | Finds and selects an item that begins with a text. |
| GetCurSel | Returns the selected item. |
| SetCurSel | Selects an item. |
| UnselectString | Clears the selection. |
| GetState | Tells whether an item is the selected one. |
| GetSelCount | Returns 1 when an item is selected, 0 otherwise. |
| GetEditSel | Reads the selection in the edit box. |
| SetEditSel | Selects characters in the edit box. |
| LimitText | Limits how much the user can type. |
| GetCueBannerText | Returns or reads the cue banner text. |
| SetCueBannerText | Sets the grey hint shown while nothing is chosen. |
| ShowDropDown | Drops the list down. |
| HideDropDown | Closes the list. |
| GetDroppedState | Tells whether the list is dropped down. |
| GetDroppedControlRect | Returns the rectangle of the control with its list dropped down. |
| GetDroppedWidth | Returns the width of the list. |
| SetDroppedWidth | Sets the smallest width of the list. |
| GetMinVisible | Returns how many items the list shows. |
| SetMinVisible | Sets how many items the list shows. |
| GetTopIndex | Returns the first visible item of the list. |
| SetTopIndex | Scrolls the list to an item. |
| GetItemHeight | Returns the height of the list items. |
| SetItemHeight | Sets the height of the list items or of the selection field. |
| GetHorizontalExtent | Returns how far the list scrolls sideways. |
| SetHorizontalExtent | Sets how far the list scrolls sideways. |
| CalcHorizontalExtent | Measures the widest item. |
| GetExtendedUI | Tells whether the extended keyboard interface is on. |
| SetExtendedUI | Turns the extended keyboard interface on or off. |
| GetLocale | Returns the locale used for sorting. |
| SetLocale | Sets the locale used for sorting. |
| GetComboBoxInfo | Returns the parts of the combo box. |
| GetEditBoxHandle | Returns the edit box. |
| GetListBoxHandle | Returns the drop-down list. |
| Enable | Enables the control. |
| Disable | Disables the control. |
| SetDarkMode | Gives the control the dark theme. |
| RemoveDarkMode | Gives the control back its normal theme. |
function AddString( byval hCombo as HWND, byval pwszText as wstring ptr ) as longAdds an item with the text pwszText. In a combo box with CBS_SORT it goes to its place in
the sorted list, otherwise to the end.
Returns the index of the new item, CB_ERR or CB_ERRSPACE.
Example
dim i as long = Combo.AddString( hCtrl, "Banana" )
Combo.SetItemData( hCtrl, i, 40 )Microsoft Learn: CB_ADDSTRING
function InsertString( byval hCombo as HWND, byval index as long, byval pwszText as wstring ptr ) as longInserts an item at position index, or at the end with -1. The list is not sorted, even with
CBS_SORT.
Returns the index of the new item, CB_ERR or CB_ERRSPACE.
Example
Combo.InsertString( hCtrl, 0, "(none)" )Microsoft Learn: CB_INSERTSTRING
function DeleteString( byval hCombo as HWND, byval index as long ) as longDeletes the item at index. The items after it move up by one.
Returns the number of items left, or CB_ERR when index is out of range.
Example
if Combo.GetCurSel( hCtrl ) <> CB_ERR then Combo.DeleteString( hCtrl, Combo.GetCurSel( hCtrl ) )Microsoft Learn: CB_DELETESTRING
sub ResetContent( byval hCombo as HWND )Deletes every item and empties the edit box.
Example
Combo.ResetContent( hCtrl )Microsoft Learn: CB_RESETCONTENT
function Dir( byval hCombo as HWND, byval attr as UINT, byval pwszFileSpec as wstring ptr ) as longAdds the names of the files and folders that match pwszFileSpec and have the attributes in
attr. Folder names are added in square brackets, drives as [-c-].
| Parameter | Meaning |
|---|---|
hCombo |
The combo box. |
attr |
DDL_READWRITE for ordinary files, combined with DDL_DIRECTORY, DDL_DRIVES, DDL_HIDDEN, DDL_SYSTEM, DDL_ARCHIVE, DDL_READONLY or DDL_EXCLUSIVE (only the attributes given). |
pwszFileSpec |
A path with wildcards, such as "C:\Windows\*.exe". |
Returns the index of the last name added, CB_ERR or CB_ERRSPACE.
Example
Combo.Dir( hCtrl, DDL_READWRITE or DDL_DIRECTORY, "*.tiko" )Microsoft Learn: CB_DIR
function GetCount( byval hCombo as HWND ) as longReturns the number of items.
Returns the count, or CB_ERR.
Example
for i as long = 0 to Combo.GetCount( hCtrl ) - 1
print Combo.GetLbText( hCtrl, i )
nextMicrosoft Learn: CB_GETCOUNT
function GetLbText( byval hCombo as HWND, byval index as long ) as ustringReturns the text of the item at index, or of the selected item when index is negative. The
string is exactly the item's text.
Returns the text, or "" when there is no such item (or no selection). GetLastError() is
the number of characters copied.
Example
print "chosen: "; Combo.GetLbText( hCtrl, -1 )Microsoft Learn: CB_GETLBTEXT
function GetLbTextLen( byval hCombo as HWND, byval index as long ) as longReturns the length of the text of the item at index.
Returns the length in characters, or CB_ERR when index is out of range.
Example
print Combo.GetLbTextLen( hCtrl, 0 )Microsoft Learn: CB_GETLBTEXTLEN
function GetText overload( byval hCombo as HWND ) as ustring
function GetText overload( byval hCombo as HWND, byval index as long ) as ustringThe first form returns the text of the selection field: what the user typed, or the selected
item. The second returns the text of the item at index. Both strings are one character longer
than the text: their last character is the null character that ends it, so len() is one more
than GetTextLength and text joined after the string is lost when it is passed
back to Windows. Remove it with rtrim( ..., chr(0) ), or use GetLbText for an
item.
Returns the text and its terminating null; for an index out of range, "" with -1 in
GetLastError().
Example
dim sTyped as ustring = rtrim( Combo.GetText( hCtrl ), chr(0) )
dim sFirst as ustring = rtrim( Combo.GetText( hCtrl, 0 ), chr(0) )Microsoft Learn: GetWindowTextW, CB_GETLBTEXT
function GetTextLength overload( byval hCombo as HWND ) as long
function GetTextLength overload( byval hCombo as HWND, byval index as long ) as longThe first form returns the length of the selection field's text; the second, the length of the
text of the item at index, as GetLbTextLen.
Returns the length in characters (CB_ERR for an index out of range).
Example
if Combo.GetTextLength( hCtrl ) = 0 then print "nothing typed"Microsoft Learn: GetWindowTextLengthW
function SetText overload( byval hCombo as HWND, byval pwszText as wstring ptr ) as boolean
function SetText overload( byval hCombo as HWND, byval index as long, byval pwszText as wstring ptr ) as longThe first form sets the text of the edit box of a CBS_DROPDOWN or CBS_SIMPLE combo box. The
second replaces the item at index by deleting it and inserting a new one in its place, so the
item's value set with SetItemData becomes 0, the selection is cleared if it was
on that item, and the list is not re-sorted.
Returns true on success (first form); the index of the new item, or CB_ERR when index
is out of range (second form).
Example
Combo.SetText( hCtrl, "typed text" )
Combo.SetText( hCtrl, 1, "Avocado" )Microsoft Learn: SetWindowTextW
function ReplaceText( byval hCombo as HWND, byval index as long, byval pwszText as wstring ptr ) as longReplaces the item at index: the same as the second form of SetText, item value and
selection included.
Returns the index of the new item, or CB_ERR when index is out of range.
Example
dim nData as LONG_PTR = Combo.GetItemData( hCtrl, 2 )
Combo.ReplaceText( hCtrl, 2, "Blood orange" )
Combo.SetItemData( hCtrl, 2, nData )function GetItemData( byval hCombo as HWND, byval index as long ) as LONG_PTRReturns the value stored with the item at index, or with the selected item when index is
negative.
Returns the value (0 when none was set), or CB_ERR.
Example
print "price"; Combo.GetItemData( hCtrl, -1 )Microsoft Learn: CB_GETITEMDATA
function SetItemData( byval hCombo as HWND, byval index as long, byval nData as LONG_PTR ) as longStores nData with the item at index: a number, or a pointer to data of your own, which the
control does not free.
Returns CB_ERR on failure.
Example
Combo.SetItemData( hCtrl, Combo.AddString( hCtrl, "Pear" ), 120 )Microsoft Learn: CB_SETITEMDATA
function FindString( byval hCombo as HWND, byval start as long, byval pwszText as wstring ptr ) as longFinds the first item whose text begins with pwszText, ignoring case. The search starts after
item start (-1 searches from the top) and wraps round to the beginning.
Returns the index of the item found, or CB_ERR.
Example
print Combo.FindString( hCtrl, -1, "ba" ) ' finds "Banana"Microsoft Learn: CB_FINDSTRING
function FindStringExact( byval hCombo as HWND, byval start as long, byval pwszText as wstring ptr ) as longFinds the first item whose whole text is pwszText, ignoring case, searching as
FindString does.
Returns the index of the item found, or CB_ERR.
Example
if Combo.FindStringExact( hCtrl, -1, "banana" ) = CB_ERR then Combo.AddString( hCtrl, "Banana" )Microsoft Learn: CB_FINDSTRINGEXACT
function SelectString( byval hCombo as HWND, byval index as long, byval pwszText as wstring ptr ) as longFinds the first item after index that begins with pwszText, as FindString
does, selects it and shows its text in the selection field. Nothing changes when no item
matches.
Returns the index of the item selected, or CB_ERR.
Example
Combo.SelectString( hCtrl, -1, "pe" ) ' selects "Pear"Microsoft Learn: CB_SELECTSTRING
function GetCurSel( byval hCombo as HWND ) as longReturns the selected item.
Returns its index, or CB_ERR when no item is selected.
Example
dim i as long = Combo.GetCurSel( hCtrl )
if i <> CB_ERR then print "item"; iMicrosoft Learn: CB_GETCURSEL
function SetCurSel( byval hCombo as HWND, byval index as long ) as longSelects the item at index, scrolls it into view and shows its text in the selection field; -1
clears the selection. The parent is not sent CBN_SELCHANGE.
Returns index, or CB_ERR when it is -1 or out of range.
Example
Combo.SetCurSel( hCtrl, 0 )Microsoft Learn: CB_SETCURSEL
function UnselectString( byval hCombo as HWND ) as longClears the selection and the selection field: SetCurSel with -1.
Returns CB_ERR, always.
Example
Combo.UnselectString( hCtrl )function GetState( byval hCombo as HWND, byval item as long ) as booleanTells whether the item at item is the selected item.
Returns true when it is.
Example
if Combo.GetState( hCtrl, 0 ) then print "the first item is selected"function GetSelCount( byval hCombo as HWND ) as longReturns how many items are selected: a combo box has at most one.
Returns 1 when an item is selected, 0 otherwise.
Example
if Combo.GetSelCount( hCtrl ) = 0 then print "nothing chosen"sub GetEditSel overload( byval hCombo as HWND, byref dwStart as DWORD, byref dwEnd as DWORD ) as DWORD
sub GetEditSel overload( byval hCombo as HWND, byval pdwStart as DWORD ptr, byval pdwEnd as DWORD ptr ) as DWORDReads the selection in the edit box: where it starts, and the first character after it. Although
it is declared as DWORD, it is a sub: it gives no value back, and using it in an expression
does not compile. Read the positions from the variables.
Example
dim as DWORD nStart, nEnd
Combo.GetEditSel( hCtrl, nStart, nEnd )
print nEnd - nStart; " characters selected"Microsoft Learn: CB_GETEDITSEL
function SetEditSel( byval hCombo as HWND, byval nStart as short, byval nEnd as short ) as longSelects the characters from nStart up to, not including, nEnd in the edit box. An nStart of
-1 removes the selection; an nEnd of -1 selects to the end.
Returns TRUE on success, CB_ERR for a CBS_DROPDOWNLIST combo box.
Example
Combo.SetEditSel( hCtrl, 0, -1 ) ' select all the typed textMicrosoft Learn: CB_SETEDITSEL
sub LimitText( byval hCombo as HWND, byval chLimit as long )Sets the most characters the user can type into the edit box; 0 removes the limit. Text already
there is not cut. GetLastError() is 1 afterwards on success.
Example
Combo.LimitText( hCtrl, 20 )Microsoft Learn: CB_LIMITTEXT
function GetCueBannerText overload( byval hCombo as HWND, byval pwszText as wstring ptr, byval cchText as DWORD ) as boolean
function GetCueBannerText overload( byval hCombo as HWND, byval cchText as DWORD = 260) as ustringReads the cue banner set with SetCueBannerText. The first form fills your
buffer of cchText characters (including the trailing null). The second returns a string of a maximum of cchText characters (260 by default).
Returns true on success (first form); the padded string (second form).
Example
dim sCue as ustring = Combo.GetCueBannerText( hCombo )
print sCueMicrosoft Learn: CB_GETCUEBANNER
function SetCueBannerText( byval hCombo as HWND, byval pwszText as wstring ptr ) as longSets a hint, drawn in grey in the selection field while it is empty, that tells the user what to choose or type.
Returns 1 on success.
Example
Combo.SetCueBannerText( hCtrl, "Choose a fruit" )Microsoft Learn: CB_SETCUEBANNER
sub ShowDropDown( byval hCombo as HWND )Drops the list of a CBS_DROPDOWN or CBS_DROPDOWNLIST combo box down.
Example
SetFocus( hCtrl )
Combo.ShowDropDown( hCtrl )Microsoft Learn: CB_SHOWDROPDOWN
sub HideDropDown( byval hCombo as HWND )Closes the dropped-down list.
Example
if Combo.GetDroppedState( hCtrl ) then Combo.HideDropDown( hCtrl )Microsoft Learn: CB_SHOWDROPDOWN
function GetDroppedState( byval hCombo as HWND ) as booleanTells whether the list is dropped down.
Returns true while it is open.
Example
print "open: "; Combo.GetDroppedState( hCtrl )Microsoft Learn: CB_GETDROPPEDSTATE
sub GetDroppedControlRect overload( byval hCombo as HWND, byval prc as RECT ptr )
sub GetDroppedControlRect overload( byval hCombo as HWND, byref rc as RECT )
function GetDroppedControlRect overload( byval hCombo as HWND ) as ( long, long, long, long )Reads the rectangle, in screen coordinates, that the combo box covers with its list dropped
down, whether it is open or not. The first two forms fill your RECT; the third returns
( left, top, right, bottom ). Each sets GetLastError() to 1 on success.
Returns the four edges (third form).
Example
var (l, t, r, b) = Combo.GetDroppedControlRect( hCtrl )
if GetLastError() then print "dropped:"; r - l; " x"; b - tMicrosoft Learn: CB_GETDROPPEDCONTROLRECT
function GetDroppedWidth( byval hCombo as HWND ) as longReturns the width of the drop-down list in pixels: the width of the control unless SetDroppedWidth made it wider.
Returns the width, or CB_ERR.
Example
print Combo.GetDroppedWidth( hCtrl )Microsoft Learn: CB_GETDROPPEDWIDTH
function SetDroppedWidth( byval hCombo as HWND, byval nWidth as long ) as longSets the smallest width, in pixels, of the drop-down list of a CBS_DROPDOWN or
CBS_DROPDOWNLIST combo box. The list is never narrower than the control.
Returns the new width, or CB_ERR.
Example
Combo.SetDroppedWidth( hCtrl, Combo.CalcHorizontalExtent( hCtrl ) + 24 )Microsoft Learn: CB_SETDROPPEDWIDTH
function GetMinVisible( byval hCombo as HWND ) as longReturns how many items the drop-down list shows before it needs a scroll bar: 30 unless set.
Returns the number of items.
Example
print Combo.GetMinVisible( hCtrl )Microsoft Learn: CB_GETMINVISIBLE
function SetMinVisible( byval hCombo as HWND, byval iMinVisible as long ) as longSets how many items the drop-down list shows before it needs a scroll bar. The list is shorter when there are fewer items.
Returns nonzero on success.
Example
Combo.SetMinVisible( hCtrl, 8 )Microsoft Learn: CB_SETMINVISIBLE
function GetTopIndex( byval hCombo as HWND ) as longReturns the item at the top of the list, 0 until the list is scrolled.
Returns its index, or CB_ERR.
Example
print "first visible item"; Combo.GetTopIndex( hCtrl )Microsoft Learn: CB_GETTOPINDEX
function SetTopIndex( byval hCombo as HWND, byval index as long ) as longScrolls the list so that the item at index is at the top, or as near the top as the end of the
list allows.
Returns 0 on success, CB_ERR on failure.
Example
Combo.SetTopIndex( hCtrl, Combo.GetCount( hCtrl ) - 1 )Microsoft Learn: CB_SETTOPINDEX
function GetItemHeight( byval hCombo as HWND ) as longReturns the height of the items in the list, in pixels. (The height of the selection field, which SetItemHeight can set with index -1, is not read here.)
Returns the height, or CB_ERR.
Example
print "rows of"; Combo.GetItemHeight( hCtrl ); " pixels"Microsoft Learn: CB_GETITEMHEIGHT
function SetItemHeight( byval hCombo as HWND, byval index as long, byval nHeight as long ) as longSets the height, in pixels, of the items in the list (index 0), or of the selection field
(index -1). In an owner-drawn CBS_OWNERDRAWVARIABLE combo box, index is the item whose
height to set.
Returns CB_ERR when the height is invalid.
Example
Combo.SetItemHeight( hCtrl, 0, 20 )
Combo.SetItemHeight( hCtrl, -1, 24 )Microsoft Learn: CB_SETITEMHEIGHT
function GetHorizontalExtent( byval hCombo as HWND ) as longReturns how wide, in pixels, the list can be scrolled sideways: 0 unless set.
Returns the scrollable width.
Example
print Combo.GetHorizontalExtent( hCtrl )Microsoft Learn: CB_GETHORIZONTALEXTENT
sub SetHorizontalExtent( byval hCombo as HWND, byval nWidth as long )Sets how wide, in pixels, the list can be scrolled sideways. When the list is narrower than
nWidth and has WS_HSCROLL, its horizontal scroll bar scrolls the items; otherwise the scroll
bar is hidden, or disabled with CBS_DISABLENOSCROLL.
Example
Combo.SetHorizontalExtent( hCtrl, Combo.CalcHorizontalExtent( hCtrl ) )Microsoft Learn: CB_SETHORIZONTALEXTENT
function CalcHorizontalExtent( byval hCombo as HWND ) as longMeasures the text of every item and returns the width of the widest, in pixels, for SetHorizontalExtent or SetDroppedWidth.
It measures with the device context's default font, not the control's: a font set with
WM_SETFONT does not change the result. It also reads each item into a buffer one character
too short for the text and its terminating null, so each call writes two bytes past a heap block
per item; programs that call it have ended later at an unrelated point. Measure with
GetTextExtentPoint32W in a device context holding the control's font instead.
Returns the width of the widest item, 0 for an empty list.
Example
dim cx as long = Combo.CalcHorizontalExtent( hCtrl )Microsoft Learn: GetTextExtentPoint32W
function GetExtendedUI( byval hCombo as HWND ) as booleanTells whether the combo box uses the extended keyboard interface, in which F4 and Down open
the list and the arrow keys do not change the selection of a closed CBS_DROPDOWNLIST combo
box.
Returns true for the extended interface.
Example
print Combo.GetExtendedUI( hCtrl )Microsoft Learn: CB_GETEXTENDEDUI
function SetExtendedUI( byval hCombo as HWND, byval flag as boolean ) as longTurns the extended keyboard interface of a CBS_DROPDOWN or CBS_DROPDOWNLIST combo box on
(true) or off.
Returns CB_OKAY (0) on success.
Example
Combo.SetExtendedUI( hCtrl, true )Microsoft Learn: CB_SETEXTENDEDUI
function GetLocale( byval hCombo as HWND ) as longReturns the locale whose rules sort the items of a CBS_SORT combo box: the user's locale
unless set.
Returns the locale identifier.
Example
print hex( Combo.GetLocale( hCtrl ) )Microsoft Learn: CB_GETLOCALE
function SetLocale( byval hCombo as HWND, byval lcid as long ) as longSets the locale whose rules sort the items that AddString adds to a CBS_SORT
combo box. Items already in the list are not re-sorted.
Returns the previous locale, or CB_ERR when lcid is not installed (the locale is then
unchanged).
Example
Combo.SetLocale( hCtrl, &h40C ) ' French (France)Microsoft Learn: CB_SETLOCALE
function GetComboBoxInfo overload( byval hCombo as HWND, byval pcbi as COMBOBOXINFO ptr ) as boolean
function GetComboBoxInfo overload( byval hCombo as HWND, byref cbi as COMBOBOXINFO ) as boolean
function GetComboBoxInfo overload( byval hCombo as HWND ) as COMBOBOXINFOReads a COMBOBOXINFO: the rectangles of the selection field and of the drop-down button, the
button's state, and the handles of the combo box's edit box (hwndItem) and list (hwndList).
cbSize is set for you. The first two forms fill your structure (the pointer form returns
false for NULL); the third returns one, with 1 in GetLastError() on success.
Returns true on success (first two forms), or the structure (third form).
Example
dim cbi as COMBOBOXINFO = Combo.GetComboBoxInfo( hCtrl )
print "button"; cbi.rcButton.right - cbi.rcButton.left; " pixels wide"Microsoft Learn: CB_GETCOMBOBOXINFO
function GetEditBoxHandle( byval hCombo as HWND ) as HWNDReturns the edit box inside a CBS_DROPDOWN or CBS_SIMPLE combo box, for the Edit
functions or to subclass it. For a CBS_DROPDOWNLIST combo box, which has none, it returns the
combo box itself.
Returns the edit box.
Example
dim hEdit as HWND = Combo.GetEditBoxHandle( hCtrl )
Edit.SetSel( hEdit, 0, -1 )Microsoft Learn: COMBOBOXINFO
function GetListBoxHandle( byval hCombo as HWND ) as HWNDReturns the list box that drops down, for the ListBox functions or to subclass it.
Returns the list box.
Example
dim hList as HWND = Combo.GetListBoxHandle( hCtrl )Microsoft Learn: COMBOBOXINFO
function Enable( byval hCombo as HWND ) as booleanLets the user use the combo box again.
Returns true when it was disabled, false when it was already enabled.
Example
Combo.Enable( hCtrl )Microsoft Learn: EnableWindow
function Disable( byval hCombo as HWND ) as booleanGreys the combo box out: it cannot take the focus or input until Enable is called.
Returns true when it was enabled, false when it was already disabled.
Example
Combo.Disable( hCtrl )Microsoft Learn: EnableWindow
function SetDarkMode( byval hCombo as HWND ) as HRESULTGives the combo box the DarkMode_CFD visual style: a dark selection field, button and list.
Returns S_OK on success.
Example
if AppsUseDarkMode() then Combo.SetDarkMode( hCtrl )Microsoft Learn: SetWindowTheme
function RemoveDarkMode( byval hCombo as HWND ) as HRESULTGives the combo box back its normal visual style.
Returns S_OK on success.
Example
Combo.RemoveDarkMode( hCtrl )Microsoft Learn: SetWindowTheme
- sys/win/gui
-
CWindow for
AddControl( "ComboBox", ... ) - CBEx for a combo box with images
- ListBox, Edit
-
gui macros and helpers for reading
WM_COMMANDin the window procedure - Dark mode
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Home
- What Is tiko-lang
- Quick Start
- Installing on macOS
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Time Zones
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing