[已解决]Radio 控件執行順序
本帖最后由 jericho0711 于 2012-4-26 18:16 编辑不知道為什麼,把Radio加上顏色後,執行的順序就不對,但是只要把GUICtrlCreateLabel這段刪除了,執行的順序就正常了,有沒有高手可以幫忙一下的...
GUICreate("Form",500,400)
Local $Radio, $L = 0
$Radio = GUICtrlCreateRadio("", 25, 80, 15,15)
GUICtrlCreateLabel("1", 42, 80, 220)
GUICtrlSetColor(-1, 0x8B0000)
$Radio = GUICtrlCreateRadio("", 25, 80+35, 15,15)
GUICtrlCreateLabel("2", 42, 80+35, 220)
GUICtrlSetColor(-1, 0x8B0000)
$Radio = GUICtrlCreateRadio("", 25, 80+35*2, 15, 15)
GUICtrlCreateLabel("3", 42, 80+35*2, 220, 20)
GUICtrlSetColor(-1, 0x8B0000)
$Button3 = GUICtrlCreateButton("START", 170, 340, 150, 40)
GuiCtrlSetState($Radio[$L], 1)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Radio To $Radio
$L = $nMsg - 3
Case $Button3
_Go1($L)
EndSwitch
WEnd
Func _Go1($iX)
Switch $iX
Case 0
MsgBox(0,"","1")
Case 1
MsgBox(0,"","2")
Case 2
MsgBox(0,"","3")
Case 3
MsgBox(0,"","4")
Case 4
MsgBox(0,"","5")
EndSwitch
EndFunc
$form1 = GUICreate("Form",500,400);;;
Local $Radio, $L = 0
$Radio = GUICtrlCreateRadio("", 25, 80, 15,15);;;
$lable1 = GUICtrlCreateLabel("1", 42, 80, 220);;;
GUICtrlSetColor(-1, 0x8B0000)
$Radio = GUICtrlCreateRadio("", 25, 80+35, 15,15);;;
$lable2 = GUICtrlCreateLabel("2", 42, 80+35, 220);;;
GUICtrlSetColor(-1, 0x8B0000)
$Radio = GUICtrlCreateRadio("", 25, 80+35*2, 15, 15);;;
$lable3 = GUICtrlCreateLabel("3", 42, 80+35*2, 220, 20);;;
GUICtrlSetColor(-1, 0x8B0000)
$Button3 = GUICtrlCreateButton("START", 170, 340, 150, 40);;
GuiCtrlSetState($Radio[$L], 1)
GUISetState()
$msg = "$form1 的控件id:" & $form1 & @CRLF
$msg &= "$Radio 的控件id:" & $Radio & @CRLF
$msg &= "$lable1 的控件id:" & $lable1 & @CRLF
$msg &= "$Radio 的控件id:" & $Radio & @CRLF
$msg &= "$lable2 的控件id:" & $lable2 & @CRLF
$msg &= "$Radio 的控件id:" & $Radio & @CRLF
$msg &= "$label2 的控件id:" & $lable3 & @CRLF
$msg &= "$Button3 的控件id:" & $Button3 & @CRLF
MsgBox(0, "debug info", $msg);;;;把这些控件id输出来看看你就明白怎么回事了
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Radio To $Radio
$L = $nMsg - 3;;;
Case $Button3
_Go1($L)
EndSwitch
WEnd
Func _Go1($iX)
Switch $iX
Case 0
MsgBox(0,"","1")
Case 1
MsgBox(0,"","2")
Case 2
MsgBox(0,"","3")
Case 3
MsgBox(0,"","4")
Case 4
MsgBox(0,"","5")
EndSwitch
EndFunc
原來是因為加上GUICtrlCreateLabel這一行,控行id不同了,難怪整個輸出的值都不同了,請問一下有辦法去改嗎,還是只能把GUICtrlCreateLabel這個控件拿掉,小弟對這種控件真的很不內行... 回复 3# jericho0711
把建立控件的顺序调一下就能达到你预期的设想了!
我顺便按你的思路优化了代码, 看起来会简洁很多!
GUICreate("Form",500,400)
Local $Radio, $L = 0
For $i = 0 To 4
$Radio[$i] = GUICtrlCreateRadio("", 25, 80+35*$i, 15,15)
Next
GuiCtrlSetState($Radio[$L], 1)
For $i = 1 To 5
GUICtrlCreateLabel($i, 45, 82+35*($i-1), 20)
GUICtrlSetColor(-1, 0x8B0000)
Next
$Button3 = GUICtrlCreateButton("START", 170, 340, 150, 40)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Radio To $Radio
$L = $nMsg - 3
Case $Button3
_Go1($L)
EndSwitch
WEnd
Func _Go1($iX)
Switch $iX
Case 0
MsgBox(0,"","1")
Case 1
MsgBox(0,"","2")
Case 2
MsgBox(0,"","3")
Case 3
MsgBox(0,"","4")
Case 4
MsgBox(0,"","5")
EndSwitch
EndFunc 回复jericho0711
把建立控件的顺序调一下就能达到你预期的设想了!
我顺便按你的思路优化了代码, 看起来 ...
user3000 发表于 2012-4-26 16:17 http://www.autoitx.com/images/common/back.gif
太感謝了,整個優化了很多,而且看起來清楚多了
页:
[1]