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
Drop-down boxes (without edit field)
I'm assuming you're dealing with an external window/combobox and unable to use PB's native SetGadgetItemText.
Simply replace hCombo with the handle to a ComboBox of your chioce.
***Edited to update code for PB 4.xx
Simply replace hCombo with the handle to a ComboBox of your chioce.
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
Last edited by Sparkie on Tue Feb 06, 2007 12:59 am, edited 1 time in total.
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1

