s77m72 发表于 2009-6-28 10:47:24

关于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这样做出来的效果是不能拖动的,有什么办法可以令到做出来的窗口可以拖动啊?

lxz 发表于 2009-6-28 11:29:22

#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

s77m72 发表于 2009-6-28 12:09:44

谢谢了~!!!!!!

s77m72 发表于 2009-6-28 17:40:44

是可以拖动了,但是加别的控件不能用了。。

298311657 发表于 2009-6-28 21:34:25

#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

298311657 发表于 2009-6-28 21:35:46

GUICtrlCreateLabel("", 0, 0, 466, 202, $WS_CLIPSIBLINGS, $GUI_WS_EX_PARENTDRAG)
创建一个大小与GUI界面一样大的label,注意它的样式~
这样就可以在使用图片做GUI背景后,还可以顺利的拖动GUI窗口了~

lxz 发表于 2009-6-29 08:03:08

#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

s77m72 发表于 2009-6-29 11:58:42

原来是这样的,谢谢了。。

kn007 发表于 2009-6-29 12:22:04

如果问题解决了,记得编辑1楼的帖子类型为已解决

dnbj2010 发表于 2010-2-27 10:09:18

不是特别好用,是可以拖动了,但是:
$Pic1 = GUICtrlCreatePic("背景.bmp", 0, 0, 465, 201, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
如果将“背景.bmp”换成真实的图片路径,窗体内的控件比如右键菜单还是失效的。

dnbj2010 发表于 2010-2-27 10:35:52

自已解决了,通过定义右键菜单GUICtrlCreateContextMenu(?)的参数,GUI图片控件上的参数有效了。
页: [1]
查看完整版本: 关于GUI加图片后拖动的问题?