Sign in to follow this  
Followers 0
dom3787

drag & drop

5 posts in this topic

#1 ·  Posted (edited)

Hi, I can drag & drop my gui with left click, but it won't work with right click, any idea why ?

$hGUI = GUICreate('', 800, 600, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))

GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")
GUIRegisterMsg($WM_RBUTTONDOWN, "_WM_RBUTTONDOWN")

Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    Local Const $SC_DRAGMOVE = 0xF012
    _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc

Func _WM_RBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    Local Const $SC_DRAGMOVE = 0xF012
    _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc

I tried commenting the left button part but it still won't work with right button.

Thanks for any infos.

Edited by dom3787

Share this post


Link to post
Share on other sites



dom3787,

If you test the code you see that the script is blocked within the "DRAGMOVE" section while the left button is pressed - while it returns instantly when called by the right button: :)

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

Global Const $SC_DRAGMOVE = 0xF012

HotKeySet("{ESC}", "On_Exit")

$hGUI = GUICreate('', 800, 600, -1, -1, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
GUISetBkColor(0xFF0000)

GUISetState()

GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")
GUIRegisterMsg($WM_RBUTTONDOWN, "_WM_RBUTTONDOWN")

While 1
    Sleep(10)

WEnd

Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    ConsoleWrite("Left pressed at: " & @MSEC & @CRLF)
    _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
    ConsoleWrite("Left released at: " & @MSEC & @CRLF)
EndFunc

Func _WM_RBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    ConsoleWrite("Right pressed at: " & @MSEC & @CRLF)
    _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
    ConsoleWrite("Right released at: " & @MSEC & @CRLF)
EndFunc

Func On_Exit()
    Exit
EndFunc
Thus it appears that you cannot use the right button to drag GUIs using this method - just as you cannot use the right button to drag normal GUIs. ;)

M23


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

#3 ·  Posted (edited)

Now that's interesting,  but as you said "using this method". Correct me if I'm wrong but I'm pretty sure I've already came across softwares where you could actually drag & drop things using the right button, so there might be a way to do it. Apparently not this one. (I guess I'm left to use mouseevent handler and move things *while the button is pressed*)

Edited by dom3787

Share this post


Link to post
Share on other sites

dom3787,

Looking at the 4 methods I describe in the Moving and Resizing PopUp GUIs tutorial in the Wiki, I would be surprised if any of them worked with the right button. :(

Windows uses the 2 buttons to do different things (left to action, right to bring up context menus) and I feel you are asking too much to expect them to act in a similar manner just for you. Someone here might well know how to do what you want - but I do not believe it will be a simple solution and I am not holding my breath waiting for it. ;)

M23


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

#5 ·  Posted (edited)

Probably uneasy but doable for sure. With years I realised that speaking of computer science, about anything is possible. Only the time you want to invest in finding the answer matters. Anyway, thanks for this wiki page*, even if it's not working for the right button it definitely will improve my knowledge on the dragging topic !

 

edit :

Resizing a $WS_POPUP GUI

that script demonstrates what it has to do but fails in a way, to crash it, start the script, click with your cursor in another window or the desktop, move your cursor on your red GUI square > crash.

Edited by dom3787

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