象QQ缩放的窗口控制怎么写?
一个最基本的窗口代码,感谢顽固不化和xtybfgu指点以及借鉴sanmoking 的代码,这个问题已经成为过去,完美解决了上下左右窗口缩放的问题,代码如下,特放出与朋友们分享。#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 - $winpos - $winpos / 2) < $winpos / 2 + 1 And Abs($mousepos - $winpos - $winpos / 2) < $winpos / 2 + 1 Then
If $winpos = 0 And $winpos = 0 Then
WinMove($Form1, "", @DesktopWidth / 2 - 150 / 2, @DesktopHeight / 2 - $winpos / 2, 150, 150, 1)
EndIf
If $winpos = 0 And $winpos <> 0 Then
WinMove($Form1, "", 0, $winpos, 200, $winpos, 1)
EndIf
If $winpos = 0 And $winpos <> 0 Then
WinMove($Form1, "", $winpos, 0, $winpos, 500, 1)
EndIf
If @DesktopWidth - $winpos - 2 = 0 Then
WinMove($Form1, "", @DesktopWidth - 200, $winpos, 200, $winpos, 1)
EndIf
If @DesktopHeight - $winpos - 2 = 0 Then
WinMove($Form1, "", $winpos, @DesktopHeight - 500, $winpos, 500, 1)
EndIf
Sleep(1)
ElseIf $winpos <= 0 Then
WinMove($Form1, "", 0, $winpos, 2, $winpos, 1)
ElseIf $winpos <= 0 Then
WinMove($Form1, "", $winpos, 0, $winpos, 2, 1)
ElseIf @DesktopWidth - $winpos - $winpos <= 0 Then
WinMove($Form1, "", @DesktopWidth - 2, $winpos, 2, $winpos, 1)
ElseIf @DesktopHeight - $winpos - $winpos <= 0 Then
WinMove($Form1, "", $winpos, @DesktopHeight - 2, $winpos, 2, 1)
EndIf
WEnd
[ 本帖最后由 wxlgh521 于 2008-6-28 18:58 编辑 ] 做一下,思索一下,,,继续改。。。。。
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 179, 444, 332, 137)
GUISetState(@SW_SHOW)
While 1
$GUIXY=WinGetPos("Form1")
if $GUIXY<30 and $GUIXY>2 then
WinMove("Form1","",$GUIXY,0)
sleep(500)
for $i=$GUIxy to 2 step -10
WinMove("Form1","",$GUIXY,0,$GUIXY,$i)
Next
EndIf
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd 原帖由 xtybfgu 于 2008-6-27 10:42 发表 http://www.autoitx.com/images/common/back.gif
只搞了左边的了。
:face (31):
#include
#include
Opt("GUIOnEventMode", 1)
opt("MouseCoordMode",0)
$Form1 = GUICreate("Form1", 179, 444, 332, 137)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOS ...
哈哈,不错呀。有个情况和我一样,就是拖到中间后还会自动跑到边上。。。。。是不是要加个窗口移动事件呀? 左边和顶部容易搞点。。。右边和下边就烦琐了。 谢谢大家,右边和下面都完美解决了 你的代码测试有问题。 。。。在XP SP3下测试失败。。。要像QQ一样,还有得改呢。 顶一下老帖, 不错,学习一下,觉得还需要改下才像QQ嘛,就是靠左或者右应该把窗体上下拉全屏才行吧:)呵呵 程序是要根据个人要达到的目的来写,而不是要完全照搬他人,当然你的程序目标就是完全模拟人家的例外。 好东西,向高手学习了。
页:
[1]