|
一个最基本的窗口代码,感谢顽固不化和xtybfgu指点以及借鉴sanmoking 的代码,这个问题已经成为过去,完美解决了上下左右窗口缩放的问题,代码如下,特放出与朋友们分享。
[au3]
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 200, 500, -1, -1, -1, $WS_EX_TOPMOST)
GUISetState(@SW_SHOW)
While 1
$winpos = WinGetPos($Form1)
$mousepos = MouseGetPos()
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
If Abs($mousepos[0] - $winpos[0] - $winpos[2] / 2) < $winpos[2] / 2 + 1 And Abs($mousepos[1] - $winpos[1] - $winpos[3] / 2) < $winpos[3] / 2 + 1 Then
If $winpos[0] = 0 And $winpos[1] = 0 Then
WinMove($Form1, "", @DesktopWidth / 2 - 150 / 2, @DesktopHeight / 2 - $winpos[3] / 2, 150, 150, 1)
EndIf
If $winpos[0] = 0 And $winpos[1] <> 0 Then
WinMove($Form1, "", 0, $winpos[1], 200, $winpos[3], 1)
EndIf
If $winpos[1] = 0 And $winpos[0] <> 0 Then
WinMove($Form1, "", $winpos[0], 0, $winpos[2], 500, 1)
EndIf
If @DesktopWidth - $winpos[0] - 2 = 0 Then
WinMove($Form1, "", @DesktopWidth - 200, $winpos[1], 200, $winpos[3], 1)
EndIf
If @DesktopHeight - $winpos[1] - 2 = 0 Then
WinMove($Form1, "", $winpos[0], @DesktopHeight - 500, $winpos[2], 500, 1)
EndIf
Sleep(1)
ElseIf $winpos[0] <= 0 Then
WinMove($Form1, "", 0, $winpos[1], 2, $winpos[3], 1)
ElseIf $winpos[1] <= 0 Then
WinMove($Form1, "", $winpos[0], 0, $winpos[2], 2, 1)
ElseIf @DesktopWidth - $winpos[0] - $winpos[2] <= 0 Then
WinMove($Form1, "", @DesktopWidth - 2, $winpos[1], 2, $winpos[3], 1)
ElseIf @DesktopHeight - $winpos[1] - $winpos[3] <= 0 Then
WinMove($Form1, "", $winpos[0], @DesktopHeight - 2, $winpos[2], 2, 1)
EndIf
WEnd
[/au3]
[ 本帖最后由 wxlgh521 于 2008-6-28 18:58 编辑 ] |
|