Jump to content

Help with dragable borderless window


am632
 Share

Recommended Posts

Hi,

I'm creating an app using ISN AutoIt Studio.

I have created my gui using the built in form editor and I have saved it as an .isf which I have included in my main script using #Include <File/Main.isf> & I show the GUI using the code line GUISetState(@SW_SHOW, $Main). I have the style 'WS_POPUP' enabled on my gui to get rid of the border, everything is working fine but now I want to make the window dragable. I have looked at all the examples here https://www.autoitscript.com/wiki/Moving_and_Resizing_PopUp_GUIs and none of them have worked for me, I dont know if its something to do with my gui being an included file rather than having the gui code in the main script but i'd like to get it working and i'd like to keep my gui as a seperate file for graphical editing purposes. (Note I have included relevant files when trying each example and I have changed the gui control name to match mine)

Please can anyone help with the matter possibly with an example?

Thanks

Link to comment
Share on other sites

Hi, Thanks for the suggestion, but it didnt work for me unfortunatly. I saved the form as an au3 file and added the code from the second example with no luck, I also tried adding it to the forms source aswell but this didnt work. Did you import the gui code into your test script or did you include the gui as an include file?

Thanks

Link to comment
Share on other sites

You can use this to move your GUI:

$hGUI = GUICreate("Your GUI", ...)
...
GUISetState(@SW_SHOW, $hGUI)
...
GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")

...

Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    _SendMessage($hGUI $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc   ;==>_WM_LBUTTONDOWN

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Hi, thanks for your reply but this also doesn't seem to work for me, I have changed the $hGui variable to be correct for my script and I have included SendMessage.au3 which I assume is needed for the function to work properly but what happens is when I click on part of the GUI to move it the script just exits. I have tried adding the code in my forms file aswell to see if this would work but still no luck. I think it must be something to do with my form being a seperate file from my main script, do you think this is the case?

Thanks

Link to comment
Share on other sites

Post your script or a reproducer script that demonstrates what you are doing so we can see where it fails. Otherwise, it's all guesswork.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hi, heres a sample script of my code.

Main script

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiButton.au3>
#Include <SendMessage.au3>
#Include <Forms/Main.isf>

#region ;Include Region
Opt("GUIOnEventMode", 1)
Opt("GUICloseOnESC", 1)
#endregion

#region ;GUI Region

GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseApplication")

GUISetState(@SW_SHOW,$Main)
GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")


#endregion

#region ;While
While 1
    Sleep(300)
WEnd
#endregion


#region ;MAIN FUNCTIONS

#region ;Exit Function
Func _CloseApplication()
    If @GUI_CtrlId = $GUI_EVENT_CLOSE Then _Exit_Command()
EndFunc   ;==>_CloseApplication

Func _Exit_Command()
        Exit
EndFunc
#endregion

Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    _SendMessage($Main, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc

#EndRegion

And here is the GUI code which is saved in a file called Main.isf in a subfolder called Forms

; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ;
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiButton.au3>

$Main = GUICreate("Main",400,270,-1,-1,$WS_POPUP,-1)
GUISetState(@SW_SHOW,$Main)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

The idea I have in mind is if you click any part of the GUI which isnt a control - in this case the grey bit, it will move the window as there is no border to interact with.

Thanks

Link to comment
Share on other sites

  • Moderators

am632,

Of course that will not work. Using #include just adds the code at the point of the #include line, so you are adding a GUIGetMsg loop into your code at which point the script pauses endlessly. Remove that loop from the .isf file and the code works. ;)

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:

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

 

Link to comment
Share on other sites

Hi,

I went to try what you said so when I opened the forms .isf file manually to remove the code it actually wasnt in there despite ISN saying it was - I guess this was a glitch as that whole while statement isnt there after all. The actual isf file looks like this...

; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ;

$Main = GUICreate("Main",400,270,-1,-1,$WS_POPUP, -1)

Out of curiosity I just ran the script streight with autoit (not using ISN Studio) and it has given me the error message 'Variable used without being declaired' on Line 51  - _SendMessage($Main, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) I shouldn't get this if I have included file SendMessage.au3 in my main script right? Or is there another file I need to include which hasn't been mensioned?

Thanks




			
		
Link to comment
Share on other sites

  • Moderators

am632,

I do not use .isf files so I cannot comment on how they work and interact with scripts. :)

As to the undeclared variable, I imagine it is this one:

Global Const $SC_DRAGMOVE = 0xF012
as I had to add it to get the code to run on my machine. ;)

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:

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

 

Link to comment
Share on other sites

Thats done it :) all working perfectly. so I just needed to add the following code to the main script for it to work.

#Include <SendMessage.au3>

Global Const $SC_DRAGMOVE = 0xF012

GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")

Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    _SendMessage($Main, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc

Thanks for all the help.

Aaron

Link to comment
Share on other sites

I just had a thought to extend on this topic, I have another window also borderless which is opened when a button is pressed on the main GUI, how can I modify the code to also allow dragging of the second window when it's opened? The only styles I have set for the second window are $WS_POPUP & WS_EX_TOPMOST (So its borderless and always on top) At the moment the main window still drags even if its clicked through the second window. I just tried adding the following line under the _SendMessage($Main, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) line

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

$HWM being the name of my second window but this didnt do anything.

Do you have any ideas please?

Thanks

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...