Code: Select all
G1 := new GUI(), G2 := new GUI()
G3 := new gui_("hello method")
Class GUI {
__New() {
local _hwnd
Gui, New, % "+Resize +Hwnd_hwnd +Label" . this.__class . "On"
Gui, Add, Edit, x0 y0 vEdit
Gui, Show, w800 h500
}
}
class gui_ { ;cf. https://autohotkey.com/boards/viewtopic.php?f=5&t=42292&p=192277#profile192277
__new(n){
this.n := n
gui new, +resize +hwndh
this.h := h
gui % this.h ":show", w200 h100
onmessage(WM_SIZE := 0x05, objbindmethod(this,"guiSize"))
onmessage(WM_SYSCOMMAND := 0x112, objbindmethod(this,"guiClose"))
; onmessage(WM_CLOSE := 0x10, objbindmethod(this,"guiClose"))
}
guiSize(wParam, lParam, msg, hwnd){
if this.h != hwnd
return
/*
0: The window has been restored, or resized normally such as by dragging its edges.
1: The window has been minimized.
2: The window has been maximized.
*/
; width and height
w := lParam & 0xFFFF
h := lParam >> 16
tooltip % w "`t" h "`t" wParam "`n" this.n
}
guiClose(wParam, lParam, msg, hwnd) { ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
if this.h != hwnd
return ; we return nothing in order to process any GuiClose label, if registered
return GUIOnClose(hwnd)
}
}
GUIOnSize(_hwnd, _eventInfo, _width, _height) {
ToolTip % _hwnd "," _eventInfo "," _width "," _height
}
GUIOnClose(_hwnd) {
MsgBox 4,, Are you sure you want to hide the GUI whose ID is %_hwnd%?
IfMsgBox No
return 1
}