Sign in to follow this  
Followers 0
MrVietA2

Problem while moving the popup GUI

2 posts in this topic

#1 ·  Posted (edited)

Hi everyone,

I have problem with this code :

#include
#include
#include
#include
Opt("GUIOnEventMode", 1)

Global $Width = 322, $Height = 183, $mWidth = 259, $mHeight = 106, $Title = "Main GUI"

_Main()

Func _Main()
Global $GUI = GUICreate($Title, $Width, $Height, -1, -1, -1)
Global $Show = GUICtrlCreateButton("Show multi GUI", 88, 64, 131, 57)
GUISetState(@SW_SHOW)
GUICtrlSetOnEvent($Show , "MultiGUI")
GUISetOnEvent($GUI_EVENT_CLOSE , "Exit1")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "On_Drag1")
EndFunc

Func MultiGUI()
$Pos = WinGetPos($Title, "")
;
If @DesktopWidth - ($Pos[0] + $Width) < $mWidth Then
$mLeft = $Pos[0] - $mWidth - 40
ElseIf $Pos[0] < $mWidth Then
$mLeft = $Pos[0] + $Width + 40
Else
$mLeft = $Pos[0] + $Width + 40
EndIf
;
GUISetState(@SW_DISABLE, $GUI)
Global $mGUI = GUICreate("Multi GUI", $mWidth, $mHeight, $mLeft, $Pos[1], BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX), $WS_EX_OVERLAPPEDWINDOW, $GUI)
GUISetState(@SW_SHOW, $mGUI)
GUISetOnEvent($GUI_EVENT_CLOSE , "Exit2")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "On_Drag2")
EndFunc

Func On_Drag1()
Const $SC_DRAGMOVE = 0xF012
_SendMessage($GUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc

Func On_Drag2()
Const $SC_DRAGMOVE = 0xF012
_SendMessage($mGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc

When multi GUI is opened, I click anywhere on main GUI, it also move multi GUI.

I can't find the way, can you tell me the solutions? Thank you

Edited by MrVietA2

Share this post


Link to post
Share on other sites



#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#include <SendMessage.au3>

Opt("GUIOnEventMode", 1)



Global $Width = 322, $Height = 183, $mWidth = 259, $mHeight = 106, $Title = "Main GUI", $hGUI1, $hGUI2, $iShow



_Main()



Func _Main()

    $hGUI1 = GUICreate($Title, $Width, $Height)

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_On_Drag1")

    $iShow = GUICtrlCreateButton("Show multi GUI", 88, 64, 131, 57)

    GUICtrlSetOnEvent(-1, "MultiGUI")

    GUISetState()

    While 1

        Sleep(1000)

    WEnd

EndFunc



Func MultiGUI()

    Local $mLeft, $Pos

    $Pos = WinGetPos($Title)



    If @DesktopWidth - ($Pos[0] + $Width) < $mWidth Then

        $mLeft = $Pos[0] - $mWidth - 40

    ElseIf $Pos[0] < $mWidth Then

        $mLeft = $Pos[0] + $Width + 40

    Else

        $mLeft = $Pos[0] + $Width + 40

    EndIf

    GUISetState(@SW_DISABLE, $hGUI1)

    $hGUI2 = GUICreate("Multi GUI", $mWidth, $mHeight, $mLeft, $Pos[1], BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX), $WS_EX_OVERLAPPEDWINDOW, $hGUI1)

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit2")

    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_On_Drag2")

    GUISetState(@SW_SHOW, $hGUI2)

EndFunc



Func _On_Drag1()

    Local Const $SC_DRAGMOVE = 0xF012

    _SendMessage($hGUI1, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)

EndFunc



Func _On_Drag2()

    Local Const $SC_DRAGMOVE = 0xF012

    _SendMessage($hGUI2, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)

EndFunc



Func _Exit()

    Exit

EndFunc



Func _Exit2()

    GUISetState(@SW_ENABLE, $hGUI1)

    GUIDelete($hGUI2)

EndFunc

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