在Case中无法返回主程序,希望能够得到帮忙
本帖最后由 xavier880819 于 2009-9-2 16:58 编辑我希望在我的程序中借用一位大侠的字移动程序#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $Y=120
$Form1 = GUICreate("字移动", 322, 205, -1, -1)
GUICtrlSetFont(-1, 24, 800, 0, "黑体")
$Label1 = GUICtrlCreateLabel("字移动的例子", 64, 24, 202, 37)
GUICtrlSetFont(-1, 24, 800, 0, "黑体")
GUISetState(@SW_SHOW,$Form1)
$Form2=GUICreate("", 322, 120, 0, 100, $WS_POPUP,$WS_EX_MDICHILD, $Form1)
$Label2 = GUICtrlCreateLabel(" 字移动的例子"&@CRLF&"欢迎访问初级视编室"&@CRLF&"http://dvedit.5d6d.com", 0, 120, 202, 50)
GUICtrlSetFont(-1, 12, 800, 0, "黑体")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW,$Form2)
#EndRegion ### END Koda GUI section ###
AdlibRegister ( "_IDmov",100 )
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Label2
ShellExecute("http://dvedit.5d6d.com")
EndSwitch
WEnd
Func _IDmov()
$Y=$Y-3
If $Y<-50 then $Y=120
GUICtrlSetPos($Label2,70,$Y)
EndFunc但是我把这个稍作修改成为一个case条件,无论我尝试使用EXIT或者EXITLOOP或者ContinueLoop都无法返回上一层的主程序,下面是我的程序Case $fileitem4
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("字移动", 322, 205, -1, -1)
GUICtrlSetFont(-1, 24, 800, 0, "黑体")
$Label1 = GUICtrlCreateLabel("字移动的例子", 64, 24, 202, 37)
GUICtrlSetFont(-1, 24, 800, 0, "黑体")
GUISetState(@SW_SHOW,$Form1)
$Form2=GUICreate("", 322, 120, 0, 100, $WS_POPUP,$WS_EX_MDICHILD, $Form1)
$Label2 = GUICtrlCreateLabel(" 字移动的例子"&@CRLF&"欢迎访问初级视编室"&@CRLF&"http://dvedit.5d6d.com", 0, 120, 202, 50)
GUICtrlSetFont(-1, 12, 800, 0, "黑体")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW,$Form2)
#EndRegion ### END Koda GUI section ###
AdlibRegister ( "_IDmov",100 )
While 2
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
ContinueLoop
Case $Label2
ShellExecute("http://dvedit.5d6d.com")
EndSwitch
WEnd
.
.
.
.
.
Func _IDmov()
$Y=$Y-3
If $Y<-50 then $Y=120
GUICtrlSetPos($Label2,70,$Y)
EndFunc 不知道你的完整代码, 终止可以 AdlibUnRegister( "_IDmov" ) 我完整在代码差不多是这样
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
case......
case......
case......
case......
case......
case......
case......(很多个不同的case)
然后再是
Case $fileitem4
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("字移动", 322, 205, -1, -1)
GUICtrlSetFont(-1, 24, 800, 0, "黑体")
$Label1 = GUICtrlCreateLabel("字移动的例子", 64, 24, 202, 37)
GUICtrlSetFont(-1, 24, 800, 0, "黑体")
GUISetState(@SW_SHOW,$Form1)
$Form2=GUICreate("", 322, 120, 0, 100, $WS_POPUP,$WS_EX_MDICHILD, $Form1)
$Label2 = GUICtrlCreateLabel(" 字移动的例子"&@CRLF&"欢迎访问初级视编室"&@CRLF&"http://dvedit.5d6d.com", 0, 120, 202, 50)
GUICtrlSetFont(-1, 12, 800, 0, "黑体")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW,$Form2)
#EndRegion ### END Koda GUI section ###
AdlibRegister ( "_IDmov",100 )
While 2
$Msg = GUIGetMsg(0)
Switch $Msg
Case $GUI_EVENT_CLOSE
ContinueLoop
Case $Label2
ShellExecute("http://dvedit.5d6d.com")
EndSwitch
WEnd
.
.
.
.
WEnd
然后下面有很多不同func直到 Func _IDmov()
$Y=$Y-3
If $Y<-50 then $Y=120
GUICtrlSetPos($Label2,70,$Y)
EndFunc
不知道这里的 While或者$Msg = GUIGetMsg会不会有冲突。 我的这个帖子已经被那个可恶的"10984811"弄得看不见了! 那个“10984811”终于没有再刷了。先把自己的问题顶上去,希望有人可以看到。:face (29): 是要做个子窗体吗? 6# netegg
就是想做个子窗体呢,但是我这样运行了子窗体好像会影响到主程序。能不能想msgbox那样可以打开,也可以关闭,又不会应该主程序的运行呢?? 我觉得我的子程序里面的$Msg = GUIGetMsg和主程序里面的 $nMsg = GUIGetMsg()有冲突,希望大家可以帮我看看能不能这样子用呢??? 代码看着有点晕~ 不如弄个简单的完整代码,然后说明你需要实现的功能可能比较好解决~ 好吧,我弄了一个简化的例子#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <File.au3>
#NoTrayIcon
Dim $Y=120,$Form1,$Msg,$Form2,$ztbj = 1,$Label1,$Label2,$checkbox13,$Button4,$checkbox1,$checkbox2,$checkbox3,$checkbox4,$checkbox5,$checkbox6,$checkbox7,$checkbox8,$checkbox9,$checkbox10,$checkbox11,$checkbox12,$Button3,$Button5,$nMsg
Opt('MustDeclareVars', 1)
GUICreate('Multi-Level Folder Creator Version 4.1', 640, 260, -1, -1)
$checkbox1 = GUICtrlCreateCheckbox("",210,17,18,18)
$checkbox2 = GUICtrlCreateCheckbox("",310,17,18,18)
$checkbox3 = GUICtrlCreateCheckbox("",410,17,18,18)
$checkbox4 = GUICtrlCreateCheckbox("",510,17,18,18)
$checkbox5 = GUICtrlCreateCheckbox("",610,17,18,18)
$checkbox6 = GUICtrlCreateCheckbox("",210,37.5,18,18)
$checkbox7 = GUICtrlCreateCheckbox("",310,37.5,18,18)
$checkbox8 = GUICtrlCreateCheckbox("",410,37.5,18,18)
$checkbox9 = GUICtrlCreateCheckbox("",510,37.5,18,18)
$checkbox10 = GUICtrlCreateCheckbox("",610,37.5,18,18)
$checkbox11 = GUICtrlCreateCheckbox("",210,58,18,18)
$checkbox12 = GUICtrlCreateCheckbox("",310,58,18,18)
$Button3 = HotKeySet("{ESC}","Terminate")
$Button4 =GUICtrlCreateButton("全选",480,55,150,26,$WS_GROUP)
$Button5 = GUICtrlCreateButton("移动字", 480, 119, 150, 26)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button4
If $ztbj = 1 Then
GUICtrlSetState($checkbox1,$GUI_CHECKED)
GUICtrlSetState($checkbox2,$GUI_CHECKED)
GUICtrlSetState($checkbox3,$GUI_CHECKED)
GUICtrlSetState($checkbox4,$GUI_CHECKED)
GUICtrlSetState($checkbox5,$GUI_CHECKED)
GUICtrlSetState($checkbox6,$GUI_CHECKED)
GUICtrlSetState($checkbox7,$GUI_CHECKED)
GUICtrlSetState($checkbox8,$GUI_CHECKED)
GUICtrlSetState($checkbox9,$GUI_CHECKED)
GUICtrlSetState($checkbox10,$GUI_CHECKED)
GUICtrlSetState($checkbox11,$GUI_CHECKED)
GUICtrlSetState($checkbox12,$GUI_CHECKED)
GUICtrlSetData($Button4, "全不选")
$ztbj = 0
Else
GUICtrlSetState($checkbox1,$GUI_UNCHECKED)
GUICtrlSetState($checkbox2,$GUI_UNCHECKED)
GUICtrlSetState($checkbox3,$GUI_UNCHECKED)
GUICtrlSetState($checkbox4,$GUI_UNCHECKED)
GUICtrlSetState($checkbox5,$GUI_UNCHECKED)
GUICtrlSetState($checkbox6,$GUI_UNCHECKED)
GUICtrlSetState($checkbox7,$GUI_UNCHECKED)
GUICtrlSetState($checkbox8,$GUI_UNCHECKED)
GUICtrlSetState($checkbox9,$GUI_UNCHECKED)
GUICtrlSetState($checkbox10,$GUI_UNCHECKED)
GUICtrlSetState($checkbox11,$GUI_UNCHECKED)
GUICtrlSetState($checkbox12,$GUI_UNCHECKED)
GUICtrlSetData($Button4, "全选")
$ztbj = 1
EndIf
Case $Button3
Terminate()
Case $Button5
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("字移动", 322, 205, -1, -1)
GUICtrlSetFont(-1, 24, 800, 0, "黑体")
$Label1 = GUICtrlCreateLabel("字移动的例子", 64, 24, 202, 37)
GUICtrlSetFont(-1, 24, 800, 0, "黑体")
GUISetState(@SW_SHOW,$Form1)
$Form2=GUICreate("", 322, 120, 0, 100, $WS_POPUP,$WS_EX_MDICHILD, $Form1)
$Label2 = GUICtrlCreateLabel(" 字移动的例子"&@CRLF&"欢迎访问初级视编室"&@CRLF&"http://dvedit.5d6d.com", 0, 120, 202, 50)
GUICtrlSetFont(-1, 12, 800, 0, "黑体")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW,$Form2)
#EndRegion ### END Koda GUI section ###
AdlibRegister ( "_IDmov",100 )
While 2
Switch $Form1
Case $GUI_EVENT_CLOSE
Exit
Case $Label2
ShellExecute("http://dvedit.5d6d.com")
EndSwitch
WEnd
EndSwitch
WEnd
Func Terminate()
Exit
EndFunc
Func _IDmov()
$Y=$Y-3
If $Y<-50 then $Y=120
GUICtrlSetPos($Label2,70,$Y)
EndFunc 点击了那个移动字以后,就无法再返回去选checkbox了 你说的这个是多窗口操作的问题~ 照你的修改了下#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <File.au3>
#NoTrayIcon
Dim $Form0, $Y = 120, $Form1, $Msg, $Form2, $ztbj = 1, $Label1, $Label2, $checkbox13, $Button4, $checkbox1, $checkbox2, $checkbox3, $checkbox4, $checkbox5, $checkbox6, $checkbox7, $checkbox8, $checkbox9, $checkbox10, $checkbox11, $checkbox12, $Button3, $Button5, $nMsg
Opt('MustDeclareVars', 1)
$Form0 = GUICreate('Multi-Level Folder Creator Version 4.1', 640, 260, -1, -1)
$checkbox1 = GUICtrlCreateCheckbox("", 210, 17, 18, 18)
$checkbox2 = GUICtrlCreateCheckbox("", 310, 17, 18, 18)
$checkbox3 = GUICtrlCreateCheckbox("", 410, 17, 18, 18)
$checkbox4 = GUICtrlCreateCheckbox("", 510, 17, 18, 18)
$checkbox5 = GUICtrlCreateCheckbox("", 610, 17, 18, 18)
$checkbox6 = GUICtrlCreateCheckbox("", 210, 37.5, 18, 18)
$checkbox7 = GUICtrlCreateCheckbox("", 310, 37.5, 18, 18)
$checkbox8 = GUICtrlCreateCheckbox("", 410, 37.5, 18, 18)
$checkbox9 = GUICtrlCreateCheckbox("", 510, 37.5, 18, 18)
$checkbox10 = GUICtrlCreateCheckbox("", 610, 37.5, 18, 18)
$checkbox11 = GUICtrlCreateCheckbox("", 210, 58, 18, 18)
$checkbox12 = GUICtrlCreateCheckbox("", 310, 58, 18, 18)
$Button3 = HotKeySet("{ESC}", "Terminate")
$Button4 = GUICtrlCreateButton("全选", 480, 55, 150, 26, $WS_GROUP)
$Button5 = GUICtrlCreateButton("移动字", 480, 119, 150, 26)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button4
If $ztbj = 1 Then
GUICtrlSetState($checkbox1, $GUI_CHECKED)
GUICtrlSetState($checkbox2, $GUI_CHECKED)
GUICtrlSetState($checkbox3, $GUI_CHECKED)
GUICtrlSetState($checkbox4, $GUI_CHECKED)
GUICtrlSetState($checkbox5, $GUI_CHECKED)
GUICtrlSetState($checkbox6, $GUI_CHECKED)
GUICtrlSetState($checkbox7, $GUI_CHECKED)
GUICtrlSetState($checkbox8, $GUI_CHECKED)
GUICtrlSetState($checkbox9, $GUI_CHECKED)
GUICtrlSetState($checkbox10, $GUI_CHECKED)
GUICtrlSetState($checkbox11, $GUI_CHECKED)
GUICtrlSetState($checkbox12, $GUI_CHECKED)
GUICtrlSetData($Button4, "全不选")
$ztbj = 0
Else
GUICtrlSetState($checkbox1, $GUI_UNCHECKED)
GUICtrlSetState($checkbox2, $GUI_UNCHECKED)
GUICtrlSetState($checkbox3, $GUI_UNCHECKED)
GUICtrlSetState($checkbox4, $GUI_UNCHECKED)
GUICtrlSetState($checkbox5, $GUI_UNCHECKED)
GUICtrlSetState($checkbox6, $GUI_UNCHECKED)
GUICtrlSetState($checkbox7, $GUI_UNCHECKED)
GUICtrlSetState($checkbox8, $GUI_UNCHECKED)
GUICtrlSetState($checkbox9, $GUI_UNCHECKED)
GUICtrlSetState($checkbox10, $GUI_UNCHECKED)
GUICtrlSetState($checkbox11, $GUI_UNCHECKED)
GUICtrlSetState($checkbox12, $GUI_UNCHECKED)
GUICtrlSetData($Button4, "全选")
$ztbj = 1
EndIf
Case $Button3
Terminate()
Case $Button5
GUISetState(@SW_DISABLE, $Form0)
$Form1 = GUICreate("字移动", 322, 205, -1, -1)
$Label1 = GUICtrlCreateLabel("字移动的例子", 64, 24, 202, 37)
GUICtrlSetFont(-1, 24, 800, 0, "黑体")
GUISetState(@SW_SHOW, $Form1)
$Form2 = GUICreate("", 322, 120, 0, 100, $WS_POPUP, $WS_EX_MDICHILD, $Form1)
$Label2 = GUICtrlCreateLabel(" 字移动的例子" & @CRLF & "欢迎访问初级视编室" & @CRLF & "http://dvedit.5d6d.com", 0, 120, 202, 50)
GUICtrlSetFont(-1, 12, 800, 0, "黑体")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetCursor(-1, 0)
GUISetState(@SW_SHOW, $Form2)
AdlibRegister("_IDmov", 100)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
GUISetState(@SW_ENABLE, $Form0)
GUISetState(@SW_HIDE, $Form1)
GUISetState(@SW_HIDE, $Form2)
ExitLoop
Case $Label2
ShellExecute("http://dvedit.5d6d.com")
EndSwitch
WEnd
EndSwitch
WEnd
Func Terminate()
Exit
EndFunc ;==>Terminate
Func _IDmov()
$Y = $Y - 3
If $Y < -50 Then $Y = 120
GUICtrlSetPos($Label2, 70, $Y)
EndFunc ;==>_IDmov 本帖最后由 netegg 于 2009-9-1 20:18 编辑
要使用子窗体的话,在GUIGetMsg()里加个参数,用GUIGetMsg(1)先获取窗体句柄,然后再考虑每个窗体里的代码
很抱歉,我没怎么这么用过,没办法更好的说明,帮助里有,不过好像说的也不是太明白,试试看吧 谢谢afan,原来可以这样设定的,又跟你学到了一招!! 谢谢netegg,你的方法我也去尝试看看
页:
[1]