Page 1 sur 1
[R] Problème GUICtrlSetData
Posté : mar. 08 juil. 2008 17:21
par autoporte
Bonjour à tous, j'ai un problème avec mon GUICtrlSetData :
► Afficher le texte
Code : Tout sélectionner
#include <GuiConstantsEx.au3>
Opt('MustDeclareVars', 1)
_Main()
Func _Main()
Local $Label_1, $Combo_2, $button1, $msg, $data , $test
GUICreate("MyGUI", 191, 157, (@DesktopWidth - 191) / 2, (@DesktopHeight - 157) / 2)
$Label_1 = GUICtrlCreateLabel("Label1", 30, 40, 131, 21, 0x1000)
$Combo_2 = GUICtrlCreateCombo("", 30, 60, 130, 21)
$test = GUICtrlSetData($Combo_2, "Item1|Item2|Item3|Item4|Item5")
$button1 = GUICtrlCreateButton("Set Label", 30, 90, 130, 20)
; Run the GUI until it is closed
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button1
$data = GUICtrlRead($Combo_2) ;Combo_2
GUICtrlSetData($Label_1, $data)
Case $msg = "Item1"
MsgBox(0,"","Item 1")
Case $msg = "Item2"
MsgBox(0,"","Item 2")
EndSelect
WEnd
Exit
EndFunc
Je voudrais que lorsque que j'ai sélectionné Item2 et appuyez sur "Set Label", un MsgBox s'affiche en disant : 'Item 2
Or codé comme ceci, il affiche Item 1
Que faire?
Re: Problème GUICtrlSetData
Posté : mar. 08 juil. 2008 17:58
par jbnh
► Afficher le texte
Code : Tout sélectionner
#include <GuiConstantsEx.au3>
Opt('MustDeclareVars', 1)
_Main()
Func _Main()
Local $Label_1, $Combo_2, $button1, $msg, $data
GUICreate("MyGUI", 191, 157, (@DesktopWidth - 191) / 2, (@DesktopHeight - 157) / 2)
$Label_1 = GUICtrlCreateLabel("Label1", 30, 40, 131, 21, 0x1000)
$Combo_2 = GUICtrlCreateCombo("", 30, 60, 130, 21)
GUICtrlSetData($Combo_2, "Item1|Item2|Item3|Item4|Item5")
$button1 = GUICtrlCreateButton("Set Label", 30, 90, 130, 20)
; Run the GUI until it is closed
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button1
If GUICtrlRead($combo_2) = "item1" Then
MsgBox(0,"","Item 1")
Elseif GUICtrlRead($combo_2) = "item2" Then
MsgBox(0,"","Item 2")
Endif
EndSelect
WEnd
Exit
EndFunc