haodd 发表于 2010-8-29 12:25:07

窗体实现可取消的默认按钮 【已解决】

本帖最后由 haodd 于 2010-8-29 13:44 编辑

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("请确认您的信息", 234, 98, 192, 114)
$Button1 = GUICtrlCreateButton("确定", 24, 48, 75, 25,-1)
;这里最后加个 -1 或者 default 已经选择了执行了
$Button2 = GUICtrlCreateButton("取消", 120, 48, 75, 25)
$Label1 = GUICtrlCreateLabel("默认10秒后运行记事本,手动点击确定立即执行记事本,点击关闭或取消关闭本程序不运行记事本", 8, 8, 214, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $nMsg = $Button1
                        Sleep(10000)
                        Run('Notepad.exe')
                        Exit
                Case $nMsg = $Button2
                        Exit
        EndSwitch
WEnd$Button1 = GUICtrlCreateButton("确定", 24, 48, 75, 25,-1)
;这里最后加个 -1 或者 default 已经选择了执行了

我想达到这种目的
运行程序后
默认10秒后运行记事本,手动点击确定立即执行记事本不用等待10秒,点击关闭或取消关闭本程序不运行记事本

需要窗体实现 不要msgbox

水木子 发表于 2010-8-29 13:13:25

#include <WindowsConstants.au3>
$Form1 = GUICreate("请确认您的信息", 234, 98, 192, 114)
$Button1 = GUICtrlCreateButton("确定", 24, 48, 75, 25, -1)
;这里最后加个 -1 或者 default 已经选择了执行了
$Button2 = GUICtrlCreateButton("取消", 120, 48, 75, 25)
$Label1 = GUICtrlCreateLabel("默认10秒后运行记事本,手动点击确定立即执行记事本,点击关闭或取消关闭本程序不运行记事本", 8, 8, 214, 33)
GUISetState()
AdlibRegister('Notepad', 10000)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case - 3, $Button2
                        Exit
                Case $Button1
                        Notepad()
        EndSwitch
WEnd

Func Notepad()
        AdlibUnRegister('Notepad')
        Run('Notepad.exe')
EndFunc   ;==>Notepad

haodd 发表于 2010-8-29 13:44:27

呵呵 有是水木谢谢哈Func Notepad()
      AdlibUnRegister('Notepad')
      Run('Notepad.exe')
      Exit
EndFunc
页: [1]
查看完整版本: 窗体实现可取消的默认按钮 【已解决】