狼兄,学习了! 本帖最后由 zerobin 于 2012-5-15 23:15 编辑
公共扩展样式里有个 $GUI_WS_EX_PARENTDRAG 允许拖动标签(label)或者图片(Pic)控件时即拖动整个父窗口。不 ...
地平线 发表于 2012-5-15 18:09 http://www.autoitx.com/images/common/back.gif
使用过,没有达到我想要的,现在是下部分窗口可以移动,但是不能操作网页了
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
Opt("GUICoordMode", 0)
Opt("GUIOnEventMode", 1)
Global $menu, $menu2, $menu3, $A1, $A2, $B1, $C1, $C2
Global $url, $Gui_h, $Gui_w, $Form1, $1, $2, $Form2, $Form3, $Label1
$url = "http://WWW.HAO123.COM"
Global $Title = "HAO123"
$Gui_w = 482
$Gui_h = 290
$Form1 = GUICreate($Title, $Gui_w, $Gui_h, -1, -1, $WS_POPUP)
caidan()
$1 = ObjCreate("Shell.Explorer.2")
$2 = GUICtrlCreateObj($1, -30, -30, $Gui_w + 50, $Gui_h)
GUICtrlSetState(-1, $GUI_HIDE)
$1.navigate($url)
GUISetState(@SW_SHOW)
GUICtrlSetState($2, $GUI_show)
While 1
Sleep(200)
WEnd
Func caidan()
$Label1 = GUICtrlCreateLabel("", 0, 0, $Gui_w, $Gui_h, $SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT);透明
$menu = GUICtrlCreateMenu("A")
$A1 = GUICtrlCreateMenuItem("HAO123", $menu)
GUICtrlSetOnEvent(-1, "_DT")
$A2 = GUICtrlCreateMenuItem("BAIDU", $menu)
GUICtrlSetOnEvent(-1, "_DT")
$menu2 = GUICtrlCreateMenu("B")
$B1 = GUICtrlCreateMenuItem("SOHU", $menu2)
GUICtrlSetOnEvent(-1, "_DT")
$menu3 = GUICtrlCreateMenu("窗口")
$C1 = GUICtrlCreateMenuItem("最小化", $menu3)
GUICtrlSetOnEvent(-1, "_DT")
$C2 = GUICtrlCreateMenuItem("退出", $menu3)
GUICtrlSetOnEvent(-1, "_DT")
EndFunc ;==>caidan
Func _DT()
Switch @GUI_CtrlId
Case $A1
GUIDelete($Form1)
$url = "http://WWW.HAO123.COM"
Global $Title = "HAO123"
$Gui_w = 420
$Gui_h = 186
$Form1 = GUICreate($Title, $Gui_w, $Gui_h, -1, -1, $WS_POPUP)
caidan()
$1 = ObjCreate("Shell.Explorer.2")
$2 = GUICtrlCreateObj($1, -1, -1, $Gui_w + 50, $Gui_h)
GUICtrlSetState(-1, $GUI_HIDE)
$1.navigate($url)
GUISetState(@SW_SHOW)
GUICtrlSetState($2, $GUI_show)
Case $A2
GUIDelete($Form1)
$url = "http://WWW.BAIDU.COM"
Global $Title = "BAIDU"
$Gui_w = 398
$Gui_h = 220
$Form1 = GUICreate($Title, $Gui_w, $Gui_h, -1, -1, $WS_POPUP)
caidan()
$1 = ObjCreate("Shell.Explorer.2")
$2 = GUICtrlCreateObj($1, -1, -50, $Gui_w + 22, $Gui_h + 50)
GUICtrlSetState(-1, $GUI_HIDE)
$1.navigate($url)
GUISetState(@SW_SHOW)
GUICtrlSetState($2, $GUI_show)
Case $B1
GUIDelete($Form1)
$url = "http://WWW.SOHU.COM"
Global $Title = "SOHU"
$Gui_w = 482
$Gui_h = 290
$Form1 = GUICreate($Title, $Gui_w, $Gui_h, -1, -1, $WS_POPUP)
caidan()
$1 = ObjCreate("Shell.Explorer.2")
$2 = GUICtrlCreateObj($1, -1, -17, $Gui_w + 50, $Gui_h)
GUICtrlSetState(-1, $GUI_HIDE)
$1.navigate($url)
GUISetState(@SW_SHOW)
GUICtrlSetState($2, $GUI_show)
Case $C1
WinSetState($Form1, "", @SW_MINIMIZE)
Case $C2
Exit
EndSwitch
EndFunc ;==>_DT
学习了谢谢 本帖最后由 zerobin 于 2012-6-4 12:00 编辑
无人指教只能自己摸索了。
现在基本实现了功能。
有瑕疵:
1、当窗口不在激活状态,鼠标移动到可见窗口区域内(此时的窗口没有被其他窗口挡住),隐藏的菜单不会出来。需要点击网页无超链处或任务栏图标,激活窗口,菜单才显示出来。
要是去掉If WinActive($Form1) Then 这个判断,当窗口全部被遮住后,鼠标进入窗口所在的坐标区域也会显示出form2菜单来。
如何解决这个问题,实现窗口未激活,在窗口部分可见(因为有其他窗口遮盖)和在窗口全部可见情况下,鼠标放在可见区域内就会GUISetState(@SW_SHOW, $Form2)呢。搜论坛,ControlGetFocus,_WinAPI_GetFocus,ControlGetHandle。我没有弄出来。
请大家指教。谢谢#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Misc.au3>
#include <WinAPI.au3>
Opt("GUICoordMode", 2)
Opt("GUIOnEventMode", 1)
Global $menu, $menu2, $menu3, $A1, $A2, $B1, $C1, $C2, $menushow = 0, $i = 1
Global $url, $Gui_h, $Gui_w, $Form1, $1, $2, $Form2, $Form3, $Label1
Global $PosDiff, $MousePos, $WinPos
$url = "http://WWW.HAO123.COM"
Global $Title = "HAO123"
$Gui_w = 482
$Gui_h = 290
$Form1 = GUICreate($Title, $Gui_w, $Gui_h, -1, -1, $WS_POPUP + $WS_EX_LAYERED)
$WinPos = WinGetPos($Form1, "")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_mousedown")
$1 = ObjCreate("Shell.Explorer.2")
$2 = GUICtrlCreateObj($1, -30, -30, $Gui_w + 50, $Gui_h)
GUICtrlSetState(-1, $GUI_HIDE)
$1.navigate($url)
_caidan()
GUISetState(@SW_HIDE, $Form2)
GUISetState(@SW_SHOW, $Form1)
GUICtrlSetState($2, $GUI_show)
While 1
_checkmenushow()
Sleep(150)
WEnd
Func _checkmenushow()
$MousePos = MouseGetPos()
$WinPos = WinGetPos($Form1)
;~ MsgBox(4096, "Get ClassName", "ClassName of " & $Form1 & ": " & _WinAPI_GetClassName($Form1),1)
;~ MsgBox(4096, "Get ClassName", "ClassName of " & $Form2 & ": " & _WinAPI_GetClassName($Form2),1)
If $MousePos > $WinPos And $MousePos < $WinPos + $WinPos And $MousePos > $WinPos And $MousePos < $WinPos + $WinPos Then
If WinActive($Form1) Then ;这样要form在激活状态下才能显示菜单,如何实现不用激活窗口,只要有可见的form1区域,鼠标移到该区域内即显示菜单呢?
GUISetState(@SW_SHOW, $Form2)
EndIf
Else
GUISetState(@SW_HIDE, $Form2)
EndIf
EndFunc ;==>_checkmenushow
Func _mousedown()
$M1 = GUIGetCursorInfo($Form1)
$M2 = GUIGetCursorInfo($Form2)
If $M1 = 0 Or $M2 = 0 Then ;点击网页中无超链接的地方和菜单空白处实现了移动窗口
$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)
;~ WinMove($Form2, "", $MousePos + $PosDiff, $MousePos + $PosDiff)
WEnd
EndIf
EndFunc ;==>_mousedown
Func _caidan()
$Form2 = GUICreate("", 200, 20, -1, -1, $WS_POPUP, $WS_EX_MDICHILD, $Form1)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_mousedown")
$menu = GUICtrlCreateMenu("菜单A")
$A1 = GUICtrlCreateMenuItem("HAO123", $menu)
GUICtrlSetOnEvent(-1, "_DT")
$A2 = GUICtrlCreateMenuItem("BAIDU", $menu)
GUICtrlSetOnEvent(-1, "_DT")
$menu2 = GUICtrlCreateMenu("菜单B")
$B1 = GUICtrlCreateMenuItem("SOHU", $menu2)
GUICtrlSetOnEvent(-1, "_DT")
$menu3 = GUICtrlCreateMenu("窗口")
$C1 = GUICtrlCreateMenuItem("最小化", $menu3)
GUICtrlSetOnEvent(-1, "_DT")
$C2 = GUICtrlCreateMenuItem("退出", $menu3)
GUICtrlSetOnEvent(-1, "_DT")
EndFunc ;==>_caidan
Func _DT()
Switch @GUI_CtrlId
Case $A1
GUIDelete($Form1)
$url = "http://WWW.HAO123.COM"
Global $Title = "HAO123"
$Gui_w = 482
$Gui_h = 290
$Form1 = GUICreate($Title, $Gui_w, $Gui_h, $WinPos, $WinPos, $WS_POPUP + $WS_EX_LAYERED)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_mousedown")
$1 = ObjCreate("Shell.Explorer.2")
$2 = GUICtrlCreateObj($1, -30, -30, $Gui_w + 50, $Gui_h)
GUICtrlSetState(-1, $GUI_HIDE)
$1.navigate($url)
_caidan()
GUISetState(@SW_HIDE, $Form2)
GUISetState(@SW_SHOW, $Form1)
GUICtrlSetState($2, $GUI_show)
Case $A2
GUIDelete($Form1)
$url = "http://WWW.baidu.COM"
Global $Title = "baidu"
$Gui_w = 482
$Gui_h = 290
$Form1 = GUICreate($Title, $Gui_w, $Gui_h, $WinPos, $WinPos, $WS_POPUP + $WS_EX_LAYERED)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_mousedown")
$1 = ObjCreate("Shell.Explorer.2")
$2 = GUICtrlCreateObj($1, -30, -30, $Gui_w + 50, $Gui_h)
GUICtrlSetState(-1, $GUI_HIDE)
$1.navigate($url)
_caidan()
GUISetState(@SW_HIDE, $Form2)
GUISetState(@SW_SHOW, $Form1)
GUICtrlSetState($2, $GUI_show)
Case $B1
GUIDelete($Form1)
$url = "http://WWW.163.COM"
Global $Title = "163"
$Gui_w = 482
$Gui_h = 290
$Form1 = GUICreate($Title, $Gui_w, $Gui_h, $WinPos, $WinPos, $WS_POPUP + $WS_EX_LAYERED)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_mousedown")
$1 = ObjCreate("Shell.Explorer.2")
$2 = GUICtrlCreateObj($1, -30, -30, $Gui_w + 50, $Gui_h)
GUICtrlSetState(-1, $GUI_HIDE)
$1.navigate($url)
_caidan()
GUISetState(@SW_HIDE, $Form2)
GUISetState(@SW_SHOW, $Form1)
GUICtrlSetState($2, $GUI_show)
Case $C1
WinSetState($Form1, "", @SW_MINIMIZE)
Case $C2
Exit
EndSwitch
EndFunc ;==>_DT
页:
1
[2]