Page 1 of 1

Gui +Resize - Caption

Posted: 17 Feb 2020, 20:46
by Kanji
Hi everyone, sorry if this question is stupid or this topic has been already debated, but i searched and i didn't find anything :(
I'd like to remove the 6px white border created by the option +resize in the GUI when there's no title bar.
In the spoiler i added an image to let you understand what I'm talking about.
Spoiler

Code: Select all

Gui, -caption +resize MinSize400x200
Gui, Color, 000
Gui, Show, w100 h50, Nome
return

Re: Gui +Resize - Caption

Posted: 17 Feb 2020, 23:50
by scriptor2016

Code: Select all

Gui, margin, -1, -1
Gui, -caption +resize MinSize400x200
Gui, Color, 000
Gui, Show, w100 h50, Nome
return

Re: Gui +Resize - Caption  Topic is solved

Posted: 18 Feb 2020, 00:47
by flyingDman
see here: https://autohotkey.com/board/topic/23969-resizable-window-border/

Code: Select all

OnMessage(0x84, "WM_NCHITTEST")
OnMessage(0x83, "WM_NCCALCSIZE")
gui, color, 000000
Gui, +resize MinSize200x200 maxsize400x400
Gui, Show, w300 h300
return

esc::
exitapp

WM_NCCALCSIZE()
{
    if A_Gui
        return 0    ; Sizes the client area to fill the entire window.
}

; Redefine where the sizing borders are.  This is necessary since
; returning 0 for WM_NCCALCSIZE effectively gives borders zero size.


WM_NCHITTEST(wParam, lParam)
{
    static border_size = 6
    
    if !A_Gui
        return
    
    WinGetPos, gX, gY, gW, gH
    
    x := lParam<<48>>48, y := lParam<<32>>48
    
    hit_left    := x <  gX+border_size
    hit_right   := x >= gX+gW-border_size
    hit_top     := y <  gY+border_size
    hit_bottom  := y >= gY+gH-border_size
    
    if hit_top
    {
        if hit_left
            return 0xD
        else if hit_right
            return 0xE
        else
            return 0xC
    }
    else if hit_bottom
    {
        if hit_left
            return 0x10
        else if hit_right
            return 0x11
        else
            return 0xF
    }
    else if hit_left
        return 0xA
    else if hit_right
        return 0xB
    
    ; else let default hit-testing be done
}

Re: Gui +Resize - Caption

Posted: 18 Feb 2020, 08:23
by Kanji
flyingDman wrote:
18 Feb 2020, 00:47
see here: https://autohotkey.com/board/topic/23969-resizable-window-border/

Code: Select all

OnMessage(0x84, "WM_NCHITTEST")
OnMessage(0x83, "WM_NCCALCSIZE")
gui, color, 000000
Gui, +resize MinSize200x200 maxsize400x400
Gui, Show, w300 h300
return

esc::
exitapp

WM_NCCALCSIZE()
{
    if A_Gui
        return 0    ; Sizes the client area to fill the entire window.
}

; Redefine where the sizing borders are.  This is necessary since
; returning 0 for WM_NCCALCSIZE effectively gives borders zero size.


WM_NCHITTEST(wParam, lParam)
{
    static border_size = 6
    
    if !A_Gui
        return
    
    WinGetPos, gX, gY, gW, gH
    
    x := lParam<<48>>48, y := lParam<<32>>48
    
    hit_left    := x <  gX+border_size
    hit_right   := x >= gX+gW-border_size
    hit_top     := y <  gY+border_size
    hit_bottom  := y >= gY+gH-border_size
    
    if hit_top
    {
        if hit_left
            return 0xD
        else if hit_right
            return 0xE
        else
            return 0xC
    }
    else if hit_bottom
    {
        if hit_left
            return 0x10
        else if hit_right
            return 0x11
        else
            return 0xF
    }
    else if hit_left
        return 0xA
    else if hit_right
        return 0xB
    
    ; else let default hit-testing be done
}
Thank you, this is exactly what i was looking for :)