窗口不是拖动的,而是定点移动
看了某某写的一个好看的GUI, 测试过后发现是拖过的,而不是定点移动过去的,请问怎么解决。?看看他的源码!
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 635, 442, 226, 157, BitOR($WS_MINIMIZEBOX, $WS_SYSMENU, $WS_POPUP, $WS_GROUP, $WS_CLIPSIBLINGS))
GUISetBkColor(0x000000)
$Tab1 = GUICtrlCreateTab(1, 24, 633, 417)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("test1")
$TabSheet2 = GUICtrlCreateTabItem("test2")
$TabSheet3 = GUICtrlCreateTabItem("test3")
$TabSheet4 = GUICtrlCreateTabItem("test4")
$TabSheet5 = GUICtrlCreateTabItem("test5")
GUICtrlCreateTabItem("")
$Label1 = GUICtrlCreateLabel("XXXX网维工具:)", 2, 1, 560, 20,$SS_CENTERIMAGE);$SS_CENTERIMAGE垂直居中,$ss_center水平居中显示
GUICtrlSetColor(-1, 0xFFFFFF)
;~ GUICtrlSetBkColor(-1, 0xabcdef)
$Label2 = GUICtrlCreateLabel("X", 620, 4, 18, 18)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label3 = GUICtrlCreateLabel("+", 592, 4, 18, 18)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label4 = GUICtrlCreateLabel("-", 564, 4, 18, 18)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Label3
If BitAND(WinGetState($Form1), 32) Then
GUISetState(@SW_RESTORE, $Form1)
Else
GUISetState(@SW_MAXIMIZE, $Form1)
EndIf
Case $Label4
GUISetState(@SW_MINIMIZE, $Form1)
Case $Label2
MsgBox(0, "提示", "程序将退出!!!")
Exit
Case $GUI_EVENT_PRIMARYDOWN
mouseCHK()
EndSwitch
WEnd
Func mouseCHK()
$MS = GUIGetCursorInfo($Form1)
If $MS = $Label1 Then move()
EndFunc ;==>mouseCHK
Func move()
Local $PosDiff, $MousePos, $WinPos
$MousePos = MouseGetPos()
$WinPos = WinGetPos($Form1, "")
$PosDiff = $WinPos - $MousePos
$PosDiff = $WinPos - $MousePos
While _IsPressed("01", DllOpen("user32.dll"))
$MousePos = MouseGetPos()
WinMove($Form1, "", $MousePos + $PosDiff, $MousePos + $PosDiff)
Sleep(10)
WEnd
EndFunc ;==>move
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 636, 442, -1, -1, $WS_POPUP)
GUISetBkColor(0x000000)
$Tab1 = GUICtrlCreateTab(1, 24, 634, 417)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("test1")
$TabSheet2 = GUICtrlCreateTabItem("test2")
$TabSheet3 = GUICtrlCreateTabItem("test3")
$TabSheet4 = GUICtrlCreateTabItem("test4")
$TabSheet5 = GUICtrlCreateTabItem("test5")
GUICtrlCreateTabItem("")
$Label1 = GUICtrlCreateLabel("XXXX网维工具:)", 2, 1, 560, 20, $SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG);$SS_CENTERIMAGE垂直居中,$ss_center水平居中显示
GUICtrlSetColor(-1, 0xFFFFFF)
;~ GUICtrlSetBkColor(-1, 0xabcdef)
$Label2 = GUICtrlCreateLabel("X", 620, 4, 18, 18)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label3 = GUICtrlCreateLabel("+", 592, 4, 18, 18)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label4 = GUICtrlCreateLabel("-", 564, 4, 18, 18)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Label3
If BitAND(WinGetState($Form1), 32) Then
GUISetState(@SW_RESTORE, $Form1)
Else
GUISetState(@SW_MAXIMIZE, $Form1)
EndIf
Case $Label4
GUISetState(@SW_MINIMIZE, $Form1)
Case $Label2
Exit
EndSwitch
WEnd 本帖最后由 afan 于 2010-7-19 11:08 编辑
再改一下,原来的那几个最小化、最大化、关闭的控件没有鼠标悬停的状态,不好。#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 636, 442, -1, -1, $WS_POPUP)
GUISetBkColor(0x000000)
$Tab1 = GUICtrlCreateTab(1, 24, 634, 417)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("test1")
$TabSheet2 = GUICtrlCreateTabItem("test2")
$TabSheet3 = GUICtrlCreateTabItem("test3")
$TabSheet4 = GUICtrlCreateTabItem("test4")
$TabSheet5 = GUICtrlCreateTabItem("test5")
GUICtrlCreateTabItem("")
$Label1 = GUICtrlCreateLabel("XXXX网维工具:)", 2, 1, 560, 20, $SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG);$SS_CENTERIMAGE垂直居中,$ss_center水平居中显示
GUICtrlSetColor(-1, 0xFFFFFF)
$Label2 = GUICtrlCreateLabel(" X", 615, 4, 18, 18)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label3 = GUICtrlCreateLabel("+", 590, 4, 18, 18)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label4 = GUICtrlCreateLabel("-", 564, 4, 18, 18)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState()
$bj = 0
While 1
$mp = GUIGetCursorInfo($Form1)
Switch $mp
Case $Label2, $Label3, $Label4
If $bj <> $mp Then Local $x = GUICtrlSetBkColor($mp, 0xA9A9A9), $bj = $mp
Case Else
If $bj <> 0 Then Local $x = GUICtrlSetBkColor($bj, 0x000000), $bj = 0
EndSwitch
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Label3
If BitAND(WinGetState($Form1), 32) Then
GUISetState(@SW_RESTORE, $Form1)
Else
GUISetState(@SW_MAXIMIZE, $Form1)
EndIf
Case $Label4
GUISetState(@SW_MINIMIZE, $Form1)
Case $Label2
Exit
EndSwitch
WEnd 谢谢afan大哥了。我去弄帮助在看看怎么写的, 不错,好东东{:face (382):} 路过。。学习下了。。 学习一下{:face (160):}
页:
[1]