Sign in to follow this  
Followers 0
KaFu

[Solved] Dragging GUI offscreen with $GUI_WS_EX_PARENTDRAG, works fine...

6 posts in this topic

#1 ·  Posted (edited)

Hiho,

does anybody know why (and how to prevent :D ) the GUI to reset to maximum top-position -25 if dragged offscreen in top direction? Drag the GUI around, no problem to drag it offscreen left, right and bottom. But if you drag more then 25 pixel offscreen to the top and release the mouse, the GUI is reset to max -25 top position? What do I have to do to drop it e.g. at -100 top?

Best Regards

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $msg

Global $win_pos_save[2]

$gui = GUICreate("My GUI",600,600) ; will create a dialog box that when displayed is centered
GUICtrlCreateLabel("",0,0,600,600, default, $GUI_WS_EX_PARENTDRAG)
GUISetState(@SW_SHOW) ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    $win_pos = WinGetPos($gui)
    if $win_pos_save[0] <> $win_pos[0] or $win_pos_save[1] <> $win_pos[1] Then
        $win_pos_save = $win_pos
        ConsoleWrite($win_pos_save[0] & @tab & $win_pos_save[1] & @crlf)
    endif
WEnd
GUIDelete()
Edited by KaFu

Share this post


Link to post
Share on other sites



Hiho,

does anybody know why (and how to prevent :D ) the GUI to reset to maximum top-position -25 if dragged offscreen in top direction? Drag the GUI around, no problem to drag it offscreen left, right and bottom. But if you drag more then 25 pixel offscreen to the top and release the mouse, the GUI is reset to max -25 top position? What do I have to do to drop it e.g. at -100 top?

Best Regards

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $msg

Global $win_pos_save[2]

$gui = GUICreate("My GUI",600,600) ; will create a dialog box that when displayed is centered
GUICtrlCreateLabel("",0,0,600,600, default, $GUI_WS_EX_PARENTDRAG)
GUISetState(@SW_SHOW) ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    $win_pos = WinGetPos($gui)
    if $win_pos_save[0] <> $win_pos[0] or $win_pos_save[1] <> $win_pos[1] Then
        $win_pos_save = $win_pos
        ConsoleWrite($win_pos_save[0] & @tab & $win_pos_save[1] & @crlf)
    endif
WEnd
GUIDelete()
Something like this almost works, but maybe it's the wrong approach.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global Const $WM_ENTERSIZEMOVE = 0x231, $WM_EXITSIZEMOVE = 0x232
Local $msg

Global $win_pos_save[2]
Global $lastpos, $moved = False, $refit
$gui = GUICreate("My GUI", 600, 600); will create a dialog box that when displayed is centered
GUICtrlCreateLabel("", 0, 0, 600, 600, Default, $GUI_WS_EX_PARENTDRAG)
GUISetState(@SW_SHOW); will display an empty dialog box
GUIRegisterMsg($WM_EXITSIZEMOVE, "Exitsm")
GUIRegisterMsg($WM_ENTERSIZEMOVE, "Entersm")
GUIRegisterMsg($WM_MOVE, "moving")
; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    $win_pos = WinGetPos($gui)
    If $win_pos_save[0] <> $win_pos[0] Or $win_pos_save[1] <> $win_pos[1] Then
        $win_pos_save = $win_pos
        ConsoleWrite($win_pos_save[0] & @TAB & $win_pos_save[1] & @CRLF)
    EndIf

    If $moved Then
        GUIRegisterMsg($WM_EXITSIZEMOVE, "")
        GUIRegisterMsg($WM_ENTERSIZEMOVE, "")
        GUIRegisterMsg($WM_MOVE, "")
        WinMove($gui, "", $lastpos[0], $refit)
        $moved = False
        GUIRegisterMsg($WM_EXITSIZEMOVE, "Exitsm")
        GUIRegisterMsg($WM_ENTERSIZEMOVE, "Entersm")
        GUIRegisterMsg($WM_MOVE, "moving")
    EndIf

WEnd
GUIDelete()

Func moving()
    If IsArray($lastpos) Then $refit = $lastpos[1]
    $lastpos = WinGetPos($gui)

    ConsoleWrite("lp1 = " & $lastpos[1] & @CRLF)
EndFunc  ;==>moving

Func Entersm()
    $lastPos = WinGetPos($gui)
EndFunc  ;==>Entersm


Func Exitsm($hWnd, $iMsg, $wP, $lP)

    If $hWnd = $gui Then


        $moved = True
    EndIf

EndFunc  ;==>Exitsm

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Something like this almost works, but maybe it's the wrong approach.

Nice remediation :D , not solving the issue itself, but a good first workaround :D , thanks for the effort!

Share this post


Link to post
Share on other sites

Nice remediation :D , not solving the issue itself, but a good first workaround :D , thanks for the effort!

Ok, maybe this is better

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <misc.au3>
Global Const $WM_ENTERSIZEMOVE = 0x231, $WM_EXITSIZEMOVE = 0x232
Local $msg

Global $win_pos_save[2]
Global $lastpos, $moved = False, $refit
$gui = GUICreate("My GUI", 600, 600); will create a dialog box that when displayed is centered
$lab = GUICtrlCreateLabel("", 0, 0, 600, 600);, Default, $GUI_WS_EX_PARENTDRAG)
GUISetState(@SW_SHOW); will display an empty dialog box
; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    $win_pos = WinGetPos($gui)
    If $win_pos_save[0] <> $win_pos[0] Or $win_pos_save[1] <> $win_pos[1] Then
        $win_pos_save = $win_pos
        ConsoleWrite($win_pos_save[0] & @TAB & $win_pos_save[1] & @CRLF)
    EndIf

    If $msg = $gui_EVENT_PRIMARYDOWN Then
        Opt("mousecoordmode",1)
        $cs = WinGetClientSize($gui)
        $mp0 = GUIGetCursorInfo();mousegetpos()
        $mp1 = mousegetpos()
        $wp1 = wingetpos($gui)
        if $mp0[4] = $lab then
         while _IsPressed(01)
            $mp2 = MouseGetPos()
            winmove($gui,"",$wp1[0]-$mp1[0] + $mp2[0],$wp1[1] - $mp1[1]+$mp2[1])

         WEnd

        EndIf

    EndIf

WEnd
GUIDelete()

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Try this:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
;

Global $hGUI = GUICreate("Drag GUI Demo", 400, 330, -1, -1, -1, $WS_EX_CLIENTEDGE)

GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUIRegisterMsg($WM_WINDOWPOSCHANGING, "WM_WINDOWPOSCHANGING")

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func WM_WINDOWPOSCHANGING($hWnd, $Msg, $wParam, $lParam)
    Local $stWinPos = DllStructCreate("uint;uint;int;int;int;int;uint", $lParam)
    
    Local $iLeft = DllStructGetData($stWinPos, 3)
    Local $iTop = DllStructGetData($stWinPos, 4)
    Local $iWidth = DllStructGetData($stWinPos, 5)
    Local $iHeight = DllStructGetData($stWinPos, 6)
    
    Local $aGUI_Pos = WinGetPos($hWnd)
    
    If $iHeight < $aGUI_Pos[3] Then
        $iNew_Top = -($aGUI_Pos[3]-$iHeight)-18 ;I am not sure that 18 will fit for all
        DllStructSetData($stWinPos, 4, $iNew_Top)
    EndIf
EndFunc

Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam)
    If $hWnd <> $hGUI Or $iMsg <> $WM_NCHITTEST Then Return $GUI_RUNDEFMSG
    
    Local $iRet = _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)
    If $iRet = 1 Then Return 2
    
    Return $iRet
EndFunc

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Ok, maybe this is better

Seems to work as intended :D , thanks for your help!

Try this:

Also works great m8, thanks for your time and effort too! Though this one seems to be defendant on some setting

;I am not sure that 18 will fit for all

, it's 25 on my computer.

Best Regards

Edited by KaFu

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