pdp320921 发表于 2011-9-8 22:09:43

回复 11# happytc BitAND($wParam, 0xFFF0)又是什么用意?
中断函数还是很模糊,AU3帮助是英文都看不懂的,汗

lixiaolong 发表于 2011-9-8 22:14:14

回复 1# pdp320921

另一种方法
#include <GUIConstantsEx.au3>

$main = GUICreate("main", 600, 400, -1, -1)
$text = GUICtrlCreateLabel("hello,world", 0, 200)
GUISetState(@SW_SHOW) ;

AdlibRegister("close", 10)

;~ While 1
        For $i = 0 To 600 Step 20
                Sleep(500)
                ControlMove($main, "", 3, $i, 200)
        Next
;~ WEnd

Func close()
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
EndFunc   ;==>close

lixiaolong 发表于 2011-9-8 22:22:30

跳出循环有很多方法
#include <GUIConstantsEx.au3>

$main = GUICreate("main", 600, 400, -1, -1)
$text = GUICtrlCreateLabel("hello,world", 0, 200)
GUISetState(@SW_SHOW) ;

Global $a = 1

AdlibRegister("close", 10)

While 1
        For $i = 0 To 600 Step 20
                Sleep(500)
                ControlMove($main, "", 3, $i, 200)
                If Not $a Then ExitLoop
        Next
        If Not $a Then ExitLoop
WEnd

Func close()
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then $a = 0
EndFunc   ;==>close

happytc 发表于 2011-9-8 22:30:12

回复 16# pdp320921


    在WM_SYSCOMMAND消息中,wParam参数的低四位(four low-order bits)是被系统使用的,所以应用程序就必须把wParam值与0xFFF0按位运算后才能正确使用。

pdp320921 发表于 2011-9-9 13:53:40

回复 19# happytc
    #include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <Misc.au3>
Opt("GUIOnEventMode", 1)
        $main=GUICreate("My GUI",600,400,-1,-1) ; 创建一个居中显示的 GUI 窗口
        ;GUISetOnEvent($GUI_EVENT_CLOSE, "close")
        ;$Edit1 = GUICtrlCreateEdit("", 600, 00, -1,-1)
       
        $text = GUICtrlCreateLabel("美丽的心情"&@CRLF&@CRLF&"速度激情"&@CRLF&@CRLF&"go go go",250,30,400,600)

        $text2= GUICtrlCreateLabel("公告栏",250,10)
        GUICtrlSetFont(-1, 10, 800, 0, "宋体")
        $button =GUICtrlCreateButton("字体",20,20)
    GUICtrlSetOnEvent(-1,"OKPressed")
        $button2 =GUICtrlCreateButton("颜色",20,50)
GUIRegisterMsg($WM_SYSCOMMAND,"WM_SYSCOMMAND")
    GUISetState(@SW_SHOW) ; 显示一个空白的窗口
        ok()

    ; 运行界面,直到窗口被关闭
    While 1
$msg = GUIGetMsg()
       
      If $msg = $GUI_EVENT_CLOSE Then ExitLoop
               
        WEnd
Func ok()       
        For $i=30 To 400 Step 5
                $arr = ControlGetPos($main,"",3)
Sleep(500)
                ControlMove("My GUI","",3,250,$i)
                If $arr>=390 Then
                        $i=30
                EndIf
       
               
        Next
EndFunc       
Func OKPressed()
_ChooseFont("Arial", 8,"","","","",$text)

EndFunc
       

Func WM_SYSCOMMAND($hWndGUI, $MsgID, $WParam, $LParam)
        Local Const $sc_close = 0xF060
        If $hWndGUI = $main Then
        Switch BitAND($WParam,0xFFF0)
                Case $sc_close
                        Exit
               
EndSwitch
EndIf
        Return $GUI_RUNDEFMSG
EndFunc试了中断的方法去跳出循环,可是再使用Opt("GUIOnEventMode", 1)这种函数调用,当点击button后,再点击关闭主窗口发现窗口出现延时

huaisha1224 发表于 2011-9-9 16:13:19

回答的相当精彩、、{:face (411):}

天堂九队 发表于 2011-9-11 23:24:29

菜鸟的我还是稀饭设个热键什么的~

紫色风林 发表于 2011-9-12 05:16:59

我没搞明白,晕

zfyczyh 发表于 2011-9-16 00:15:56

我也学习啦!

zfyczyh 发表于 2011-9-16 00:16:39

原来au3还提供中断函数呀?
页: 1 [2]
查看完整版本: 如何从循环中跳出?