GUIGetMsg模式下,怎样在最小化之前执行代码?
想实现的效果是,按最小化后,先弹出提示框,再最小化。有没有例子?
#include <GUIConstantsEx.au3>
GUICreate("获取事件消息", 400, 280)
GUISetState(@SW_SHOW)
While 1
$idMsg = GUIGetMsg()
Select
Case $idMsg = $GUI_EVENT_CLOSE
Exit
Case $idMsg = $GUI_EVENT_MINIMIZE
MsgBox("", "", "对话框最小化")
EndSelect
WEnd
除了钩子还有其他办法吗?
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPISys.au3>
Global Const $SC_MINIMIZE = 0xF020 ;最小化按钮
Global Const $SC_CLOSE = 0xF060 ;关闭按钮
GUIRegisterMsg($WM_SYSCOMMAND, 'WM_SYSCOMMAND')
$Gui = GUICreate("12", 440, 170)
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $GUI_EVENT_MINIMIZE
EndSwitch
WEnd
Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
Switch BitAND($wParam, 0xFFFF)
Case $SC_MINIMIZE
MsgBox(0,0,0)
Case $SC_CLOSE
If BitAND(_WinAPI_GetAsyncKeyState(27), 0x8000) = 0 Then
Exit
Else
MsgBox(0, "_WinAPI_GetAsyncKeyState", "Esc 键被点击, 退出.")
Return 0
EndIf
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_SYSCOMMAND
钩子已经是底层的方法了,估计没有更好的方法了
页:
[1]