Code: Alles auswählen
#combo = 1
Procedure ComboboxAutoComplete(WindowID, Message, wParam, lParam)
Protected comboWert.s, comboIndex.l, comboLang.l, comboStart.l, parameter.l
Protected start.l, ende.l
result = #PB_ProcessPureBasicEvents
Select Message
Case #WM_COMMAND
Select lParam
Case GadgetID(#combo)
Select (wParam >> 16 & $FFFF)
Case #CBN_EDITUPDATE
If GetAsyncKeyState_(#VK_BACK) Or GetAsyncKeyState_(#VK_DELETE)
;tu nix
Else
comboWert = GetGadgetText(#combo)
comboIndex = SendMessage_(lParam, #CB_FINDSTRING, -1, @comboWert)
comboStart = Len(comboWert)
;Länge des eingegebenen Textes
If comboIndex >= 0
SendMessage_(lParam, #CB_SETCURSEL, comboIndex, 0)
comboLang = Len(GetGadgetText(#combo))
;Länge des gefundenen Textes
parameter = (comboLang << 16 & $FFFFFFFF) + comboStart
SendMessage_(lParam, #CB_SETEDITSEL, 0, parameter)
EndIf
EndIf
EndSelect
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0, 40, 40, 300, 400,"Combobox", #PB_Window_SystemMenu)
ComboBoxGadget(#combo, 10, 40, 150, 20, #PB_ComboBox_Editable)
SetWindowCallback(@ComboboxAutoComplete())
SendMessage_(GadgetID(#combo),#CB_SHOWDROPDOWN,1,0)
SetCursor_(LoadCursor_(0, #IDC_ARROW) )
SetActiveGadget(#combo)
AddGadgetItem(#combo, -1, "Angela")
AddGadgetItem(#combo, -1, "Beate")
AddGadgetItem(#combo, -1, "Belinda")
AddGadgetItem(#combo, -1, "Brigitte")
AddGadgetItem(#combo, -1, "Britta")
AddGadgetItem(#combo, -1, "Brittney")
AddGadgetItem(#combo, -1, "Claudia")
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
End
Code: Alles auswählen
case WM_CREATE:
hwndCombo = CreateWindow("Combobox"), NULL, WS_CHILD | WS_VISIBLE |
CBS_SIMPLE, 100, 20, 140, 120, hwnd, (HMENU)ID_LIST,
(HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL);
for (i = 0; i<=7; i++)
{
SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)datensatz[i]);
}