;Autor: mesozorn EnableExplicit Structure comboboxinfo cbSize.l rcItem.RECT rcButton.RECT stateButton.l hwndCombo.l hwndEdit.l hwndList.l EndStructure Global cbinfo.comboboxinfo Global oldcomboProc Define tb Procedure.i ComboAutoComplete(hWnd, uMsg, wParam, lParam) Protected result Protected acg Protected spos.l Protected epos.l Protected matchesfound Protected x Protected match Protected ks Protected addchar$ Select uMsg Case #WM_CHAR acg=GetActiveGadget() SendMessage_(hwnd, #EM_GETSEL, @spos.l, @epos.l) matchesfound=0 For x=0 To CountGadgetItems(acg)-1 If LCase(Left(GetGadgetText(acg),spos)+LCase(Chr(wParam)))=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(wparam)) Else addchar$=UCase(Chr(wparam)) EndIf SetGadgetText(acg,Left(GetGadgetText(acg),spos)+addchar$+Mid(GetGadgetItemText(acg,match),spos+2)) SendMessage_(hwnd, #EM_SETSEL, spos+1, epos+999) result=0 Else result = CallWindowProc_(oldcomboproc, hWnd, uMsg, wParam, lParam) EndIf Default result = CallWindowProc_(oldcomboproc, hWnd, uMsg, wParam, lParam) EndSelect ProcedureReturn result EndProcedure If OpenWindow(0,0,0,500,250,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) ComboBoxGadget(1,10,10,200,20,#PB_ComboBox_Editable) cbinfo\cbsize=SizeOf(comboboxinfo) GetComboBoxInfo_(GadgetID(1),@cbinfo) tb=cbinfo.comboboxinfo\hwndedit oldcomboproc = SetWindowLongPtr_(tb, #GWL_WNDPROC, @ComboAutoComplete()) AddGadgetItem(1, -1, "12345") AddGadgetItem(1, -1, "23/468") AddGadgetItem(1, -1, "483~47") AddGadgetItem(1, -1, "58237") AddGadgetItem(1, -1, "58.772") Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow EndIf