Recherche une chaîne
#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_FindStringExact ( $hWnd, $sText [, $iIndex = -1] )
$hWnd | Handle du contrôle |
$sText | Chaîne à rechercher |
$iIndex | [optionnel] Index, compté à partir de 0, de l'élément qui précède le premier élément à rechercher |
Succès: | Retourne un index, compté à partir de 0, de l'élément trouvé. |
Échec: | Retourne -1. |
Trouve la première chaîne qui correspond à la chaîne spécifiée dans le paramètre $sText.
Lorsque la recherche atteint la fin de la zone de liste, la fonction continue à partir du haut de la zone de liste pour retourner à l'élément spécifié par $iIndex.
Si $iIndex vaut -1, la zone de liste est parcourue en entier depuis le début.
#include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $hGUI, $hImage, $sDelimiter = "; ", $hCombo Opt("GUIDataSeparatorChar", $sDelimiter) ; Crée une GUI $hGUI = GUICreate("ComboBoxEx Find String Exact", 400, 300) $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "This is; mY tExT", 2, 2, 394, 100, $CBS_SIMPLE) GUISetState(@SW_SHOW) $hImage = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146) _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16)) _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) _GUICtrlComboBoxEx_BeginUpdate($hCombo) For $x = 0 To 8 _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x) Next _GUICtrlComboBoxEx_EndUpdate($hCombo) ; Cherche la chaîne exacte MsgBox($MB_SYSTEMMODAL, "Information", "Found at: " & _GUICtrlComboBoxEx_FindStringExact($hCombo, "mY tExT")) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example