Code: Select all
inst := new MyGui
class MyGui
{
__New() {
Gui, New, +hwndhGui
Gui, Add, Button, hwndhButton gMyGui.On_Button, Click to see handles
Gui, Add, Text, y+10 Right, % "Button HWND: " . hButton
Gui, Add, Text, wp Right, % "Gui HWND: " . hGui
Gui, Show, w300 h100
}
On_Button() {
MsgBox, % Format("This: {:#x}`nGui HWND: {:#x}`nA_Gui: {:#x}", this
, DllCall("GetAncestor", "Ptr", this, "UInt", GA_ROOT := 2, "Ptr")
, A_Gui)
}
}