本帖最后由 KLU3K 于 2010-11-30 19:22 编辑
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 171, 77, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Combo1 = GUICtrlCreateCombo("", 12, 12, 145, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "请选择|1+1=?|2+2=?", "请选择")
GUICtrlSetOnEvent(-1, "Combo1Change")
$Label1 = GUICtrlCreateLabel("↑在上面选一个吧!", 12, 44, 146, 17, $SS_CENTER)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(100)
WEnd
Func Combo1Change()
$Ver = GUICtrlRead($Combo1)
Select
Case $Ver = "请选择"
GUICtrlSetData($Label1, "别选我啊!往下选!")
Case $Ver = "1+1=?"
GUICtrlSetData($Label1, "等于2")
Case $Ver = "2+2=?"
GUICtrlSetData($Label1, "不会做!囧rz")
EndSelect
EndFunc ;==>Combo1Change
Func Form1Close()
Exit
EndFunc ;==>Form1Close
↑以上代码选择后文字直接发生变化,无确定按钮
↓以下代码是按下确定按钮后文字发生变化
#include <ComboConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 171, 77, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Combo1 = GUICtrlCreateCombo("", 12, 12, 100, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "请选择|1+1=?|2+2=?", "请选择")
$Button1 = GUICtrlCreateButton("确定", 116, 8, 47, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
$Label1 = GUICtrlCreateLabel("↑在上面选一个吧!", 12, 44, 146, 17, $SS_CENTER)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(100)
WEnd
Func Button1Click()
$Ver = GUICtrlRead($Combo1)
Select
Case $Ver = "请选择"
GUICtrlSetData($Label1, "别选我啊!往下选!")
Case $Ver = "1+1=?"
GUICtrlSetData($Label1, "等于2")
Case $Ver = "2+2=?"
GUICtrlSetData($Label1, "不会做!囧rz")
EndSelect
EndFunc ;==>Button1Click
Func Form1Close()
Exit
EndFunc ;==>Form1Close
第一个部分代码是选择后直接生效,第二部分是按确定按钮才生效。
如果有用,给个评分! |