[已解决]看看这段代码哪里不对,最后总是退出(代码已整理)
本帖最后由 青河 于 2011-3-30 12:11 编辑#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
$Form2 = GUICreate("系统", 350, 100, -1, -1)
$Label1 = GUICtrlCreateLabel("请选择:", 22, 16, 150, 24)
GUICtrlSetFont(-1, 15, 400, 0, "黑体")
$Label1 = GUICtrlCreateLabel("请选择:", 22, 46, 150, 24)
GUICtrlSetFont(-1, 15, 400, 0, "黑体")
$Checkbox1 = GUICtrlCreateCheckbox("1重", 200, 15, 40, 17)
$Checkbox2 = GUICtrlCreateCheckbox("2重", 250, 15, 51, 17)
$Combo1 = GUICtrlCreateCombo("1", 200, 45, 100, 100)
GUISetState(@SW_SHOW)
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|", "1")
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Checkbox1
If GUICtrlRead($Checkbox1) = 1 Then
$zc = ControlGetText("系统", "", "Button1")
MsgBox(1, "系统", "你选择:" & $zc)
Else
$zc = ""
MsgBox(1, "系统", "你选择:" & $zc)
EndIf
Case $Checkbox2
If GUICtrlRead($Checkbox2) = 1 Then
$zdc = ControlGetText("系统", "", "Button2")
MsgBox(1, "系统", "你选择:" & $zdc)
Else
$zdc = ""
MsgBox(1, "系统", "你选择:" & $zdc)
EndIf
Case $Combo1
$pp = ControlGetText("", "", "Edit1")
$N = MsgBox(1 + 4144, "系统", "你选择:" & $pp & @CRLF & "你选择了:" & $zc & $zdc)
If $N = 1 Then
ExitLoop
EndIf
EndSwitch
WEnd
这段代码如果全选没有问题,但是如果单独选一个复选框就莫名其妙的退出了,代码整理好了 本帖最后由 netegg 于 2011-3-30 02:48 编辑
把格式整理好了再说,看不明白 每看蛋蛋的回复经常觉得有些突兀.但一深入细想,总能发现一些玄妙. 代码整理好了,请netegg 看一下,谢谢 不明白你这段代码是干什么的
前面加上Global $zc,$zdc 不明白楼主想干什么,但是下面这样可能不会退出#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
Local $zc,$zdc,$pp,$N
$Form2 = GUICreate("系统", 350, 100, -1, -1)
$Label1 = GUICtrlCreateLabel("请选择:", 22, 16, 150, 24)
GUICtrlSetFont(-1, 15, 400, 0, "黑体")
$Label1 = GUICtrlCreateLabel("请选择:", 22, 46, 150, 24)
GUICtrlSetFont(-1, 15, 400, 0, "黑体")
$Checkbox1 = GUICtrlCreateCheckbox("1重", 200, 15, 40, 17)
$Checkbox2 = GUICtrlCreateCheckbox("2重", 250, 15, 51, 17)
$Combo1 = GUICtrlCreateCombo("1", 200, 45, 100, 100)
GUISetState(@SW_SHOW)
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|", "1")
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Checkbox1
If GUICtrlRead($Checkbox1) = 1 Then
$zc = ControlGetText("系统", "", "Button1")
MsgBox(1, "系统", "你选择:" & $zc)
Else
$zc = ""
MsgBox(1, "系统", "你选择:" & $zc)
EndIf
Case $Checkbox2
If GUICtrlRead($Checkbox2) = 1 Then
$zdc = ControlGetText("系统", "", "Button2")
MsgBox(1, "系统", "你选择:" & $zdc)
Else
$zdc = ""
MsgBox(1, "系统", "你选择:" & $zdc)
EndIf
Case $Combo1
$pp = ControlGetText("", "", $Combo1)
$N = MsgBox(1 + 4144, "系统", "你选择:" & $pp & @CRLF & "你选择了:" & $zc & $zdc)
EndSwitch
WEnd $zc没定义,你这段里只有在$Checkbox1点击之后,才会有$zc
不知道你的确切意图,可以给你改改,不知道合不合意,只是为了让程序正常,不代表是你要的效果
把你的case $combo1换成下面的
Case $Combo1
$pp = ControlGetText("", "", "Edit1")
If $zc Then
$N = MsgBox(1 + 4144, "系统", "你选择:" & $pp & @CRLF & "你选择了:" & $zc & $zdc)
EndIf
If $N = 1 Then
ExitLoop
EndIf
我就是这个意思,在主界面不管点什么都不退出,到子界面点确定才退出,谢谢大家的指导! 本帖最后由 netegg 于 2011-3-30 12:17 编辑
回复 8# 青河
那就再简化点
Case $Combo1
$pp = ControlGetText("", "", "Edit1")
If $zc Then
MsgBox(1 + 4144, "系统", "你选择:" & $pp & @CRLF & "你选择了:" & $zc & $zdc)
ExitLoop
EndIf
页:
[1]