#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPISys.au3>
Global $Button1=0, $Form1, $Form2, $a
Opt("GUIOnEventMode", 1)
my_gui()
Func my_gui(); 主窗口
$Form1 = GUICreate("Form1", 452, 282)
GUISetOnEvent($GUI_EVENT_CLOSE, "MYGUI_CLOSE")
$Button1 = GUICtrlCreateButton('弹出子窗', 184, 56, 62, 25);,$BS_MULTILINE
GUICtrlSetOnEvent($Button1, "TANCHU")
GUISetState(@SW_SHOW)
EndFunc ;==>my_gui
While 1
Sleep(100)
WEnd
Func TANCHU()
MYGUI2()
EndFunc ;==>TANCHU
Func MYGUI_CLOSE()
Exit
EndFunc ;==>MYGUI_CLOSE
Func MYGUI2();次窗口,启动后鼠标没有点击在次窗口区域内,退出
$Form2 = GUICreate("Form1", 300, 200,-1,-1,$Form1)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")
GUIRegisterMsg($WM_MOUSELEAVE, "WM_MOUSELEAVE")
EndFunc ;==>MYGUI2
Func WM_MOUSEMOVE($hWnd, $Msg, $wParam, $lParam)
$tagTRACKMOUSEEVENT = DllStructCreate("DWORD cbSize;DWORD dwFlags;HWND hwndTrack;DWORD dwHoverTime")
DllStructSetData($tagTRACKMOUSEEVENT, "cbSize", DllStructGetSize($tagTRACKMOUSEEVENT)) ;结构体缓冲区大小
DllStructSetData($tagTRACKMOUSEEVENT, "dwFlags", BitOR($TME_HOVER,$TME_LEAVE)) ;注册WM_MOUSEHOVER和$WM_MOUSELEAVE消息
DllStructSetData($tagTRACKMOUSEEVENT, "hwndTrack", $hWnd) ;当前窗口句柄
DllStructSetData($tagTRACKMOUSEEVENT, "dwHoverTime", 300) ;触发的时间300ms
$TRACKMOUSEEVENT = DllStructGetPtr($tagTRACKMOUSEEVENT)
DllCall("user32.dll", "bool", "TrackMouseEvent","ptr",$TRACKMOUSEEVENT)
EndFunc ;==>WM_MOUSEMOVE
Func WM_MOUSELEAVE($hWnd, $Msg, $wParam, $lParam)
GUIDelete($Form2)
EndFunc ;==>MYGUI2_CLOSE
|