Code: Select all
#NoEnv
#Persistent
#SingleInstance Ignore
Gui, Margin , 0, 0
Gui, Add, Button, x10 y3 h18 w76 gchbox_3 vBut3, Button 1
Gui, Add, Button, x100 y3 h18 w76 gchbox_4 vBut4, Button 2
Gui, Font, s10
Gui, Add, Text , x10 y40 cLime , Please, in order to see the problem: `n-------------------------------------------- `n `n(1)First click on button 1 `n `n(2)Second click on button 2 `n `n(3)Third click in any area outside the GUI
Gui +Maxsize%A_ScreenWidth%x%A_ScreenHeight% +Minsize250x60
Gui, -0x30000 ; WS_MINIMIZEBOX := 0x20000, WS_MAXIMIZEBOX := 0x10000 ; no min and no max icons on top menu bar
Gui, color, c5d5d5d
Gui, Show ,w300 h300, My Sticky Notes
Return
chbox_3:
T3 := !T3
If (T3) ; or --> If T3 = 1
{
Gui, -Caption
OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x84, "WM_NCHITTEST")
OnMessage(0x83, "WM_NCCALCSIZE")
OnMessage(0x86, "WM_NCACTIVATE")
WinGetPos, XX1, YY1, WW1, HH1 , A
Sleep 10
Gui, +0x30000 ; WS_MINIMIZEBOX := 0x20000, WS_MAXIMIZEBOX := 0x10000 ; add min and max icons on top menu bar
Gui, +LastFound
WinMove,,,%XX1%, %YY1%, %WW1%
}
Else
{
Gui, +Caption
OnMessage(0x201, "WM_LBUTTONDOWN",0)
OnMessage(0x84, "WM_NCHITTEST",0)
OnMessage(0x83, "WM_NCCALCSIZE",0)
OnMessage(0x86, "WM_NCACTIVATE",0)
WinGetPos, XX2, YY2 , WW2, HH2 , A
Sleep 10
Gui, -0x30000 ; WS_MINIMIZEBOX := 0x20000, WS_MAXIMIZEBOX := 0x10000 ; no min and no max icons on top menu bar
Gui, +LastFound
WinMove,,,, , %WW2%
}
Return
chbox_4:
FreezeGui2 := !FreezeGui2
IfEqual,FreezeGui2,1
{
WinGetPos, X1, Y1, W1, H1 , A
Gui, +Resize
Sleep 10
Gui, +0x30000 ; WS_MINIMIZEBOX := 0x20000, WS_MAXIMIZEBOX := 0x10000 ; add min and max icons on top menu bar
Gui, +LastFound
WinMove,,,%X1%, %Y1%, %W1%
}
Else
{
WinGetPos, X2, Y2, W2, H2 , A
Gui, -Resize
Sleep 10
Gui, -0x30000 ; WS_MINIMIZEBOX := 0x20000, WS_MAXIMIZEBOX := 0x10000 ; no min and no max icons on top menu bar
Gui, +LastFound
WinMove,,,, , %W2%
}
Return
GuiClose:
goto ExitAll
Return
ExitAll:
ExitApp
; Allow moving the GUI by dragging any point in its client area.
WM_LBUTTONDOWN()
{
if A_Gui
PostMessage, 0xA1, 2 ; WM_NCLBUTTONDOWN
}
; Sizes the client area to fill the entire window.
WM_NCCALCSIZE()
{
if A_Gui
return 0
}
; Prevents a border from being drawn when the window is activated.
WM_NCACTIVATE()
{
if A_Gui
return 1
}
; 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
}