Jump to content

Recommended Posts

Posted

MouseCoordMode sets whether MouseGetPos() is relative or absolute. In this case, you want relative.

Test MouseGetPos() whether its in the top 20 pixels when a mouse and the $GUI_EVENT_PRIMARYDOWN event on GuiGetMsg. If the two are true, use WinMove() to move your window along with the cursor.

Good luck :mellow:

Posted

Ok I got this far but I'm stuck with the WinMove().

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

Opt("MouseCoordMode", 2)

$Form1 = GUICreate("Form1", 501, 344, 192, 124, BitOR($WS_POPUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            $mPos = MouseGetPos()
            If $mPos[1] < 20 Then
                WinMove() ; I'm stuck here
            EndIf
    EndSwitch
WEnd
  • Moderators
Posted

Final version,

2 solutions for you:

1. Use $SC_DRAGMOVE on the whole GUI:

#include <GuiconstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>

Global Const $SC_DRAGMOVE = 0xF012

HotKeySet("{ESC}", "On_Exit")
Func On_Exit()
    Exit
EndFunc

$hGUI = GUICreate("X", 50, 50, -1, -1, BitOR($WS_POPUP,$WS_BORDER), $WS_EX_TOPMOST)
GUISetBkColor(0xFF0000, $hGUI)
GUISetState()

While 1

    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_PRIMARYDOWN
            _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
    EndSwitch
WEnd

2: Use $GUI_WS_EX_PARENTDRAG on a label:

#include <GuiconstantsEx.au3>
#include <WindowsConstants.au3>

HotKeySet("{ESC}", "On_Exit")
Func On_Exit()
    Exit
EndFunc

$hGUI = GUICreate("X", 50, 50, -1, -1, BitOR($WS_POPUP,$WS_BORDER), $WS_EX_TOPMOST)
$hLabel = GUICtrlCreateLabel("", 0, 0, 50, 50, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, 0x00FF00)
GUISetState()

While 1

    Sleep(10)

WEnd

Personally I prefer the former. :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

Posted

Your example, combined with his example, makes what you need. It's also better than tracking mousePos and using winMove yourself.

Posted

$SC_DRAGMOVE. :mellow:

Sometihng like this:

$mPos = MouseGetPos()
 If $mPos[1] < 20 Then
 _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
 EndIf
Posted

using WM_NCHITTEST you can specify the parts as you want

#include <GuiconstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>

Global Const $SC_DRAGMOVE = 0xF012

HotKeySet("{ESC}", "On_Exit")
Func On_Exit()
    Exit
EndFunc

$hGUI = GUICreate("X", 300, 100, -1, -1, BitOR($WS_POPUP,$WS_BORDER), $WS_EX_TOPMOST)
GUISetBkColor(0xFF0000, $hGUI)
GUIRegisterMsg($WM_NCHITTEST, "_MY_NCHITTEST")
GUISetState()

While 1

    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            Exit
    EndSwitch
WEnd

Func _MY_NCHITTEST($hWnd, $uMsg, $wParam, $lParam)
    ; Author: Prog@ndy
    Switch $hWnd
        Case $hGUI
            Local $aPos = WinGetPos($hWnd)
            ; BitAnd(BitShift($lParam, 16),0xFFFF) will return HIWORD
            If Abs(BitAND(BitShift($lParam, 16),0xFFFF)- $aPos[1]) < 20 Then Return $HTCAPTION ; the first 20 px from top will be TitleBar
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

  • Moderators
Posted

ProgAndy,

Nice one. :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...