本帖最后由 zjimmy 于 2009-9-9 11:49 编辑
我利用UDF搞成了这段代码,方法比较“土”,可能不够高级,希望有所帮助。#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
Global $PreBtnDown
$Form1 = GUICreate("Form1", 227, 59, 192, 124)
$Button1 = GUICtrlCreateButton("确定", 16, 16, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("取消", 112, 16, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $GUI_EVENT_PRIMARYDOWN
Select
Case _ButtonIsDown($Button1, $PreBtnDown)
MsgBox(0, "", "你按下了【确定】按钮")
Case _ButtonIsDown($Button2, $PreBtnDown)
MsgBox(0, "", "你按下了【取消】按钮")
EndSelect
Case $GUI_EVENT_PRIMARYUP
Select
Case _ButtonIsRelease($Button1, $PreBtnDown)
MsgBox(0, "", "你松开了【确定】按钮")
Case _ButtonIsRelease($Button2, $PreBtnDown)
MsgBox(0, "", "你松开了【取消】按钮")
EndSelect
EndSwitch
WEnd
Func _ButtonIsDown($hBtn, ByRef $hPreBtnDown)
If BitAND(_GUICtrlButton_GetState($hBtn), $BST_PUSHED) Then
$hPreBtnDown = $hBtn
Return 1
Else
Return 0
EndIf
EndFunc ;==>_ButtonIsDown
Func _ButtonIsRelease($hBtn, ByRef $hPreBtnDown)
If $hBtn <> $hPreBtnDown Then Return 0
If BitAND(_GUICtrlButton_GetState($hBtn), $BST_PUSHED) Then
$hPreBtnDown = $hBtn
Return 0
Else
Return 1
EndIf
EndFunc ;==>_ButtonIsRelease
|