Jump to content

Moving a window with no titlebar...?


sensalim
 Share

Recommended Posts

Do you want to move it within the script or be able to move it?

" I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln

Link to comment
Share on other sites

Sorry :D I want to move it within the script...

If you mean that the window to move is created in the script that is moving it then you have, or can have the handle to the window because that is what is returned by GuiCreate. Handles can be used instead of titles, and they're more reliable.

WinMove($hGui,"",$x,$y)
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.
Link to comment
Share on other sites

If my GUI has no title bar, how do I move it?

I've seen the code from someone before in this forum but I can't find it.

Can anyone help?

Thanks.

This?

#include <GuiConstants.au3>

;Global Const $HTCLIENT = 0x1
;Global Const $HTCAPTION = 0x2

$hGui = GUICreate("Test", 300, 200, -1, -1, BitOR($WS_POPUP, $WS_BORDER))

GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")

GUISetState()

Do
Until GUIGetMsg() = -3

Func WM_NCHITTEST($hWnd, $Msg, $wParam, $lParam)
    Local $iProc
    
    $iProc = DllCall("user32.dll", "int", "DefWindowProc", "hwnd", $hWnd, "int", $Msg, "wparam", $wParam, "lparam", $lParam)
    $iProc = $iProc[0]
    
    If $iProc = $HTCLIENT Then Return $HTCAPTION
    
    Return $GUI_RUNDEFMSG
EndFunc
Link to comment
Share on other sites

This is a more elaborate version to setting a simple label to move the window. :D

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=d:\my documents\Files\AU3\My Scripts\Abook\coolGUI.kxf
$Form1 = GUICreate("Form1", 801, 601, -1, -1, BitOR($WS_POPUP, $WS_BORDER))
GUISetBkColor (0xDDDDDD)
$Label1 = GUICtrlCreateLabel("", 0, 0, 800, 20, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetResizing (-1, $GUI_DOCKHEIGHT+$GUI_DOCKLEFT+$GUI_DOCKRIGHT)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label2 = GUICtrlCreateLabel("Label2", 24, 2, 539, 18, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetResizing (-1, $GUI_DOCKSIZE+$GUI_DOCKRIGHT+$GUI_DOCKLEFT)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$title_close = GUICtrlCreateLabel("X", 788, 2, 12, 18)
GUICtrlSetResizing (-1, $GUI_DOCKSIZE+$GUI_DOCKRIGHT)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$title_max = GUICtrlCreateLabel("[]", 774, 0, 12, 20)
GUICtrlSetResizing (-1, $GUI_DOCKSIZE+$GUI_DOCKRIGHT)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$title_min = GUICtrlCreateLabel("_", 762, 0, 12, 20)
GUICtrlSetResizing (-1, $GUI_DOCKSIZE+$GUI_DOCKRIGHT)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$icon = GUICtrlCreatePic (@Systemdir & "\oobe\images\mslogo.jpg", 1, 1, 18, 18, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetImage (-1, @SystemDir & "\shell32.dll", 22, 0)
GUICtrlSetResizing (-1, $GUI_DOCKSIZE+$GUI_DOCKLEFT)
;GUICtrlSetBkColor(-1, 0x000000)
GUISetState(@SW_SHOW)
#EndRegion ### START Koda GUI section ### Form=d:\my documents\Files\AU3\My Scripts\Abook\coolGUI.kxf
$hover1 = False
$hover2 = False
$hover3 = False
$unhover1 = False
$unhover2 = False
$unhover3 = False
$maxmized = False
$mousoverbtns = 0
While 1
    $nMsg = GUIGetMsg()
    $mousover = GUIGetCursorInfo()
    If IsArray($mousover) Then
        $mousoverbtns = $mousover[4]
    Else
        $mousoverbtns = 0
    EndIf
    Select
        Case $nMsg = $GUI_EVENT_CLOSE or $nMsg = $title_close
            Exit
        Case $nMsg = $title_min
            GUISetState (@SW_MINIMIZE)
        Case $nMsg = $title_max
            If $maxmized Then
                $maxmized = False
                GUISetState (@SW_RESTORE)
            Else
                $maxmized = True
                GUISetState (@SW_MAXIMIZE)
            EndIf
        Case $mousoverbtns <> 0
            If $mousover[4] = $title_close Then
                If $hover1 <> True Then
                    GUICtrlSetColor($title_close, 0xDDDDDD)
                    $hover1 = True
                    $unhover1 = True
                EndIf
            ElseIf $mousover[4] = $title_min Then
                If $hover2 <> True Then
                    GUICtrlSetColor($title_min, 0xDDDDDD)
                    $hover2 = True
                    $unhover2 = True
                EndIf
            ElseIf $mousover[4] = $title_max Then
                If $hover3 <> True Then
                    GUICtrlSetColor($title_max, 0xDDDDDD)
                    $hover3 = True
                    $unhover3 = True
                EndIf
            EndIf
        Case $mousoverbtns == 0
            If $unhover1 = True Then
                $hover1 = False
                $unhover1 = False
                GUICtrlSetColor($title_close, 0xFFFFFF)
                GUICtrlSetColor($title_max, 0xFFFFFF)
                GUICtrlSetColor($title_min, 0xFFFFFF)
            ElseIf $unhover2 = True Then
                $hover2 = False
                $unhover2 = False
                GUICtrlSetColor($title_close, 0xFFFFFF)
                GUICtrlSetColor($title_max, 0xFFFFFF)
                GUICtrlSetColor($title_min, 0xFFFFFF)
            ElseIf $unhover3 = True Then
                $hover3 = False
                $unhover3 = False
                GUICtrlSetColor($title_close, 0xFFFFFF)
                GUICtrlSetColor($title_max, 0xFFFFFF)
                GUICtrlSetColor($title_min, 0xFFFFFF)
            EndIf
    EndSelect
WEnd
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...