Moin!
Neuer Tag, neues Problem ;(:
Ich hab mir einen String erstellt (in diesem Beispiel sowas wie ne Einkaufsliste) und ich habe ne Combobox. Nun will ich aber das, wenn es eine überstimmung zwischen dem geschriebenem text in der combobox und meinem string besteht, diese Übereinstimmung + der rest vom wort im string in die liste der combobox gestellt wird..quasi sowas wie ein autocomplete bei suchseiten wie google..
So ungefähr klappt mein script auch:
Spoiler anzeigen
#include <array.au3>
#include <Inet.au3>
#include <GuiComboBox.au3>
#include <String.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
$gui = GuiCreate("Main Gui", 300,300)
$Combo = GuiCtrlCreateCombo("Einkaufsliste...", 35, 150)
$BUtton = GuiCtrlCreateButton("OK", 240,148)
GuiSetState()
Global $Einkaufsliste = "| Apfel| Birne| Cola| Datteln| Eis| Fleisch| Gemüse| Hefe| Ingwer| Joghurt| Kaffee| Lachs| Mais| Nutella| Obst| Pizza| Quark| Reis| Salz| Tee| U| Vanillezucker| Wasser| X| Y| Zucker"
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
While 1
Wend
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit
If Not IsHWnd($Combo) Then $hWndEdit1 = GUICtrlGetHandle($Combo)
$hWndFrom = $ilParam
$iIDFrom = _WinAPI_LoWord ($iwParam)
$iCode = _WinAPI_HiWord ($iwParam)
Switch $hWndFrom
Case $Combo, $hWndEdit1
Switch $iCode
Case $CBN_EDITCHANGE
If StringInStr($Einkaufsliste, "| " & GUICtrlRead($Combo)) Then
$string1 = StringInStr($Einkaufsliste, "| " & GUICtrlRead($Combo),Default, 1)
$string2 = StringMid($Einkaufsliste, $string1+2)
$string3 = StringInStr($string2, "|", Default, 1)
$string4 = StringMid($string2, 1, $string3-1)
$string5 = _GuiCtrlComboBox_GetListArray($Combo)
If $string5[1] = "Einkaufsliste..." Then
_GuiCtrlComboBox_DeleteString($Combo, $string5[1])
EndIf
If $string5[0] > 1 Then
For $i = 1 To $string5[0]
If $string5[$i] <> $string4 Then
_GuiCtrlComboBox_DeleteString($Combo, $string5[$i])
EndIf
Next
EndIf
_GuiCtrlCombobox_InsertString($Combo, $string4)
_GuiCtrlComboBox_ShowDropDown($Combo, true)
EndIf
EndSwitch
EndSwitch
EndFunc
Aber es gibt ein paar Probleme die ich gerne beseitigen will:
1.Beim ersten mal wenn ich nur 1 Buchstabe eingebe, wird der text in der combobox schon sofort auf die Übereinstimmung gesetzt ohne das
man irgendeinen anderen buchstaben schreiben darf... Im prinzip will ich das nichts mit dem geschriebenen text in der combobox gemacht wird sondern nur das sich die liste der combobox verändert!
2.Wenn dann nun die Liste der Combobox aufgeht, verschwindet der mauscursor hinter der gui was extremst nervig ist..das könnte an _GuiCtrlComboBox_ShowDropDown liegen!
3.Nachdem es nur noch 1 Übereinstimmung gibt, wird nach jedem buchstaben diese übereinstimmung noch 1 zusätzliches mal in die liste gesetzt, sodass bei dem Wort "Apfel", 5xApfel in der Liste steht. Ich will das immer nur 1 item in der liste ist, das die näheste übereinstimmung anzeigt..
Soo das wärs erstmal! =)
MFG, Apfel