Jump to content

Dragging window


Recommended Posts

Hola,

Is it possible to make a part of a window w/o titlebar (or at least an alternative titlebar by using images) draggable, so you can drag it over the screen by clicking the "virtual" titlebar?

Thanks in advance!

Link to comment
Share on other sites

I was thinking maybe a simulation would fit for the purpose. You click a button or an image in this case and:

1) The cursor changes to the one with 4 arrows

2) The cursor will track moves and update the window position w/ the new co-ords asap

3) When the mouse button is released, the cursor reverts and it will stop tracking movements.

Link to comment
Share on other sites

Are you guys thinking too hard lately?

#include <guiconstants.au3>
Opt("GuiOnEventMode", 1)
$HTCAPTION = 2
$WM_NCLBUTTONDOWN = 0xA1
$winttl = "Test"
$guihndl = GUICreate($winttl, 500, 300, -1, -1)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "captureit")
GUISetState(@SW_SHOW)
Sleep(50000)

func captureit()
  dllcall("user32.dll","int","ReleaseCapture")
  dllcall("user32.dll","int","SendMessage","hWnd", $guihndl,"int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0)
EndFunc

Drag the window with the body.

Who else would I be?
Link to comment
Share on other sites

Srry I have a small offtopic question but I dont want to filth the forum with another thread; My GUI is partially transparent and has an image overlay. You can compare it to Winamp, an image based GUI. The problem is, when I place a button ON the image it does not; 1) Get the "pushed" look when clicked 2) Perform its task.

Is there a reason why a button on a transparent image behaves weird?

Link to comment
Share on other sites

It does seem to have a problem with the $GUI_EVENT_PRIMARYDOWN; my button stops working and I think it doesnt react because the PRIMARYDOWN action overrules the button also. Is there a way to prevent this?

-Edit- Code added.

#include <Constants.au3>
#include "GUIConstants.au3"
#include <Array.au3>

;Global stuff
FileChangeDir(@Scriptdir)
#NoTrayIcon

;Vars
$HTCAPTION = 2
$WM_NCLBUTTONDOWN = 0xA1

;The script
$pic=GUICreate("", 472, 297, 1024/2-472/2, 768/2-297/2,$WS_POPUP)
GUISetState(@SW_SHOW)

$gui=GUICtrlCreatePic ("window.gif", 0, 0, 472, 297)
GUISetState(@SW_SHOW)

GUICtrlSetState($gui, $GUI_DISABLE)

$btnx=GUICtrlCreateButton('Hello World',40,40,100,20)
GUISetState(@SW_SHOW)

func captureit()
  dllcall("user32.dll","int","ReleaseCapture")
  dllcall("user32.dll","int","SendMessage","hWnd", $pic,"int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0)
EndFunc

Do
    $msg = GUIGetMsg(1)
    Select
    Case $msg[0]= $GUI_EVENT_PRIMARYDOWN
            captureit()
        Case $msg[0]= $btnx
                        MsgBox(0,"Button click", "Clicked on btnx")
        Case $msg[0]= $GUI_EVENT_CLOSE
            MsgBox(0,"Close", "Closing window.")
            Exit
    EndSelect
Until $msg = $GUI_EVENT_CLOSE
Edited by FrashMX
Link to comment
Share on other sites

Try this one: <= removed

Please upload Your script with images.

Edit: GUISetOnEvent

OnEvent functions are only called when the option GUIOnEventMode is set to 1 - when in this mode GUIGetMsg is NOT used at all.

... GUICtrlSetState, I think that the buttons can't work constantly.

EDIT: Added new script with button functionality Transparent_GUI.rar

Edited by eJan
Link to comment
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
 Share

  • Recently Browsing   0 members

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