Drop-down boxes (without edit field)
Posted: Mon Jun 13, 2005 5:48 pm
I know the handle of a dropdown box without an edit field in a window. How would I be able to change the text of the currently displayed item?
- Matt
- Matt
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
If OpenWindow(0, 0, 0, 270, 140, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
hCombo = ComboBoxGadget(0, 10, 10, 250, 100)
ButtonGadget(1, 10, 120, 250, 20, "Change current item text")
For i = 0 To 4
AddGadgetItem(0, -1, "ComboBox item " + Str(i))
Next i
SetGadgetState(0, 2)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget And EventGadget() = 1
; --> Get the current selection in ComboBox
currentSelection = SendMessage_(hCombo, #CB_GETCURSEL, 0, 0)
; --> Create new text
newText$ = "New text for item " + Str(currentSelection)
; --> Delete the item at current selection
SendMessage_(hCombo, #CB_DELETESTRING, currentSelection, 0)
; --> Insert the new item at current selection
SendMessage_(hCombo, #CB_INSERTSTRING, currentSelection, @newText$)
; --> Select the new item
SendMessage_(hCombo, #CB_SETCURSEL, currentSelection, 0)
EndIf
Until Event = #PB_Event_CloseWindow
EndIf