本帖最后由 yingf20 于 2010-9-13 11:11 编辑
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("TrayMenuMode", 1)
Opt("GUICloseOnESC", 0)
Opt("TrayOnEventMode", 1)
HotKeySet('{F2}', 'f2')
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("测试", 200, 100, 200, 200, $WS_POPUP, $WS_EX_TOOLWINDOW)
$Button = GUICtrlCreateButton("关闭", 162, 128, 40, 20)
_SetWindowPos($Form1, 200, 200) ;这里设置窗口始终在最前端
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $Button
GUISetState(@SW_HIDE)
EndSwitch
WEnd
Func f2()
If WinGetState($Form1) Then
GUISetState(@SW_HIDE)
Else
GUISetState(@SW_SHOW)
EndIf
EndFunc ;==>SpecialEvent
Func _SetWindowPos($hWnd, $x, $y) ;使用API将窗体保持最前
Local $cX, $cY
Dim $hWndInsertAfter = -1
Dim $wFlags = 1
DllCall("user32.dll", "long", "SetWindowPos", "long", $hWnd, "long", $hWndInsertAfter, "long", $x, _
"long", $y, "long", $cX, "long", $cY, "long", $wFlags)
EndFunc ;==>_SetWindowPos
试试这些代码看怎样。看是不是你想要的。 |