Code: Select all
Structure comboboxinfo
cbSize.l
rcItem.RECT
rcButton.RECT
stateButton.l
hwndCombo.l
hwndEdit.l
hwndList.l
EndStructure
cbinfo.comboboxinfo
OpenWindow(0, 0, 0, 270, 140, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ComboBoxGadget(0, 10, 10, 250, 21, #PB_ComboBox_Editable)
AddGadgetItem(0, -1, "Adams")
AddGadgetItem(0, -1, "Franklin")
AddGadgetItem(0, -1, "Jefferson")
AddGadgetItem(0, -1, "Walters")
AddGadgetItem(0, -1, "Washington")
SetActiveGadget(0)
Repeat
W=WaitWindowEvent()
If W=#WM_KEYDOWN And GetActiveGadget()=0
acg=GetActiveGadget()
cbinfo\cbsize=SizeOf(comboboxinfo)
GetComboBoxInfo_(GadgetID(acg),@cbinfo)
tb=cbinfo.comboboxinfo\hwndedit
SendMessage_(tb, #EM_GETSEL, @spos.l, @epos.l)
matchesfound=0
For x=0 To CountGadgetItems(acg)-1
If LCase(Left(GetGadgetText(acg),spos)+LCase(Chr(EventwParam())))=LCase(Left(GetGadgetItemText(acg,x),spos+1)) And epos=Len(GetGadgetText(acg))
matchesfound+1:match=x
If matchesfound>1:Break:EndIf
EndIf
Next x
If matchesfound=1
ks=GetKeyState_(#VK_SHIFT)
If ks<2:addchar$=LCase(Chr(EventwParam())):Else:addchar$=UCase(Chr(EventwParam())):EndIf
SetGadgetText(acg,Left(GetGadgetText(acg),spos)+addchar$+Mid(GetGadgetItemText(acg,match),spos+2))
SendMessage_(tb, #EM_SETSEL, spos+1, epos+999)
PeekMessage_(@msg.MSG, GadgetID(acg), #WM_KEYFIRST, #WM_KEYLAST, #PM_REMOVE)
EndIf
EndIf
Until W = #PB_Event_CloseWindow