SzymonKaczmarek Posted December 14, 2012 Share Posted December 14, 2012 (edited) So, I create one parent gui($hWnd1) and one child gui($hWnd2). And I want to move GUI with only clicking on parent gui, but I can move everywhere my gui. How to fix it? This is simple code: #include #include #include #include Opt("GUICloseOnESC", 0) $hWnd1 = GUICreate("Window 1", 717, 477, -1, -1, BitOR($WS_VISIBLE, $WS_POPUP, 0x80000000, 0x00080000, 0x00000008)) GUISetBkColor(0x000000) $hWnd2 = GUICreate("Window 2", 717, 457, 0, 20, BitOR($WS_CHILD, $WS_VISIBLE), -1, $hWnd1) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($hWnd1) ExitLoop Case $GUI_EVENT_PRIMARYDOWN _SendMessage($hWnd1, $WM_SYSCOMMAND, 0xF012, 0) EndSwitch WEnd Sorry for my bad english. Edited December 14, 2012 by SzymonKaczmarek Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 14, 2012 Moderators Share Posted December 14, 2012 (edited) SzymonKaczmarek, Here is one way to do it: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> ; Please do not use "magic numbers" - we have the $WS constants for a reason ;) Global Const $SC_DRAGMOVE = 0xF012 ; And there are "magic numbers here too!!! $hWnd1 = GUICreate("Window 1", 717, 20, -1, -1, BitOR($WS_POPUP, 0x80000000, 0x00080000, 0x00000008)) GUISetBkColor(0xFF0000) GUISetState() $hWnd2 = GUICreate("Window 2", 717, 457, -1, -1, $WS_POPUP) GUISetBkColor(0xCCFFCC) GUISetState() $aPos = WinGetPos($hWnd1) WinMove($hWnd2, "", $aPos[0], $aPos[1] + 20) GUIRegisterMsg($WM_MOVE, "_Move_Both") While 1 $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $hWnd1 Switch $aMsg[0] Case $GUI_EVENT_PRIMARYDOWN _SendMessage($hWnd1, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndSwitch EndSwitch WEnd Func _Move_Both($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam Switch $hWnd Case $hWnd1 Local $aPos = WinGetPos($hWnd1) WinMove($hWnd2, "", $aPos[0], $aPos[1] + 20) EndSwitch EndFunc All clear? M23 Edit: And welcome to the AutoIt forum. Edited December 14, 2012 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
SzymonKaczmarek Posted December 14, 2012 Author Share Posted December 14, 2012 Oh thank you very much, but I learning autoIt about half year Link to comment Share on other sites More sharing options...
SzymonKaczmarek Posted December 14, 2012 Author Share Posted December 14, 2012 Oh, I have bug. When you active something window and re-active this window by red gui (parent) then you see like this: http://scr.hu/6l0/8k7ey I waiting for help :3 My english is not too bad? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 15, 2012 Moderators Share Posted December 15, 2012 SzymonKaczmarek,Try this version. You will need my GUIScrollbarsEx UDF - the link is in my sig.: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> #include <GUIScrollbars_Ex.au3> Global Const $SC_DRAGMOVE = 0xF012 ; Create main GUI $hGUI_Main = GUICreate("", 400, 400, -1, -1, $WS_POPUP) ; Add some labels to show scrolling GUICtrlCreateLabel("", 0, 0, 350, 350) GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlCreateLabel("", 350, 350, 350, 350) GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlCreateLabel("", 0, 350, 350, 350) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlCreateLabel("", 350, 0, 350, 350) GUICtrlSetBkColor(-1, 0x00FF00) GUISetState(@SW_SHOW) ; Add scrollbars _GUIScrollbars_Generate($hGUI_Main, 700, 700) ; Create the bar $hGUI_Bar = GUICreate("Test", 400, 1, -1, -1, $WS_POPUP) GUISetBkColor(0x0000FF) GUISetState(@SW_SHOW) $aPos = WinGetPos($hGUI_Main) WinMove($hGUI_Bar, "", $aPos[0], $aPos[1] - 27, $aPos[2], 27) GUIRegisterMsg($WM_MOVE, "StickTogether") While 1 $aMsg = GUIGetMsg(1) If $aMsg[1] = $hGUI_Bar And $aMsg[0] = $GUI_EVENT_PRIMARYDOWN Then _SendMessage($hGUI_Bar, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndIf WEnd Func StickTogether($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam Switch $hWnd Case $hGUI_Bar Local $aPos = WinGetPos($hGUI_Bar) WinMove($hGUI_Main, "", $aPos[0], $aPos[1] + 26) EndSwitch EndFuncAny better? M23P.S. Your English is fine. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now