J'utilise ce code pour auto compléter mes ComboBox.
Si je choisis la valeur dans la liste en cliquant avec la souris, l'index est bien retourné lorsque je clique sur le bouton +.
Si j'utilise l'auto completion, la valeur de l'index retournée est -1.
Comment faire en sorte d'actualiser la sélection de la ComboBox ?
Code : Tout sélectionner
#include <GuiComboBox.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
$hGUI = GUICreate("", 220, 80)
GUICtrlCreateLabel("User", 20, 20)
Global $g_idCombo_User = GUICtrlCreateCombo("", 20, 20, 150, 20)
GUICtrlSetData(-1, "Jean|Marius|Marina|Marie")
Local $idButton_AddUser = GUICtrlCreateButton("+", 175, 19, 23, 23)
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $idButton_AddUser
MsgBox(0, "", _GUICtrlComboBox_GetCurSel($g_idCombo_User))
EndSwitch
WEnd
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg
Local $hWndFrom, $iIDFrom, $iCode, $hWndCombo_User
If Not IsHWnd($g_idCombo_User) Then $hWndCombo_User = GUICtrlGetHandle($g_idCombo_User)
$hWndFrom = $lParam
$iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word
$iCode = BitShift($wParam, 16) ; Hi Word
Switch $hWndFrom
Case $g_idCombo_User, $hWndCombo_User
Switch $iCode
Case $CBN_EDITCHANGE ; Sent after the user has taken an action that may have altered the text in the edit control portion of a combo box
_GUICtrlComboBox_AutoComplete($g_idCombo_User)
; no return value
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND