关于GUI加图片后拖动的问题?
本帖最后由 s77m72 于 2009-6-29 12:58 编辑代码如下:#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 466, 202, -1, -1, BitOR($WS_POPUP,$WS_CLIPSIBLINGS))
$Pic1 = GUICtrlCreatePic("背景.bmp", 0, 0, 465, 201, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Progress1 = GUICtrlCreateProgress(24, 144, 417, 25)
GUICtrlSetData(-1, 20)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd这样做出来的效果是不能拖动的,有什么办法可以令到做出来的窗口可以拖动啊? #include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Global $wmp = ObjCreate("WMPlayer.OCX")
$Form1 = GUICreate("Form1", 466, 202, -1, -1, BitOR($WS_POPUP,$WS_CLIPSIBLINGS))
$Pic1 = GUICtrlCreatePic("背景.bmp", 0, 0, 465, 201, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Progress1 = GUICtrlCreateProgress(24, 144, 417, 25)
GUICtrlSetData(-1, 20)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $GUI_EVENT_PRIMARYDOWN
mouseCHK()
EndSwitch
WEnd
Func mouseCHK()
$MS = GUIGetCursorInfo($Form1)
If $MS = $Pic1 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", 466, 202, -1, -1, BitOR($WS_POPUP,$WS_CLIPSIBLINGS))
$Pic1 = GUICtrlCreatePic("背景.bmp", 0, 0, 465, 201, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Progress1 = GUICtrlCreateProgress(24, 144, 417, 25)
GUICtrlSetData(-1, 20)
GUICtrlCreateLabel("", 0, 0, 466, 202, $WS_CLIPSIBLINGS, $GUI_WS_EX_PARENTDRAG);创建一个大小与GUI界面一样大的label
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd GUICtrlCreateLabel("", 0, 0, 466, 202, $WS_CLIPSIBLINGS, $GUI_WS_EX_PARENTDRAG)
创建一个大小与GUI界面一样大的label,注意它的样式~
这样就可以在使用图片做GUI背景后,还可以顺利的拖动GUI窗口了~ #include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Global $wmp = ObjCreate("WMPlayer.OCX")
$Form1 = GUICreate("Form1", 466, 202, -1, -1, BitOR($WS_POPUP,$WS_CLIPSIBLINGS))
$button1 = GUICtrlCreateButton ("退出", 350, 50, 70, 25)
$Pic1 = GUICtrlCreatePic("背景.bmp", 0, 0, 465, 201, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Progress1 = GUICtrlCreateProgress(24, 144, 417, 25)
GUICtrlSetData(-1, 20)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE,$button1
Exit
Case $GUI_EVENT_PRIMARYDOWN
mouseCHK()
EndSwitch
WEnd
Func mouseCHK()
$MS = GUIGetCursorInfo($Form1)
If $MS = $Pic1 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 原来是这样的,谢谢了。。 如果问题解决了,记得编辑1楼的帖子类型为已解决 不是特别好用,是可以拖动了,但是:
$Pic1 = GUICtrlCreatePic("背景.bmp", 0, 0, 465, 201, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
如果将“背景.bmp”换成真实的图片路径,窗体内的控件比如右键菜单还是失效的。 自已解决了,通过定义右键菜单GUICtrlCreateContextMenu(?)的参数,GUI图片控件上的参数有效了。
页:
[1]