Sign in to follow this  
Followers 0
SzymonKaczmarek

Hello I have a problem with moving my GUI

5 posts in this topic

#1 ·  Posted (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 by SzymonKaczmarek

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

SzymonKaczmarek,

Here is one way to do it: ;)

#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 by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Oh thank you very much, but I learning autoIt about half year ;)

Share this post


Link to post
Share on other sites

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? :)

Share this post


Link to post
Share on other sites

SzymonKaczmarek,

Try this version. You will need my GUIScrollbarsEx UDF - the link is in my sig.: ;)

#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

EndFunc

Any better? :)

M23

P.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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0