In the example blow. I just try to pass this.test() as Glabel.
Code: Select all
Test1 := new TestClass("Test1", 500, 600)
; Test2 := new TestClass("Test2", 450, 400)
; Test3 := new TestClass("Test3", 600, 400)
return
class TestClass {
__New(Name, x, y) {
Gui, New, +Hwndhwnd
Gui %hwnd%: -Caption +AlwaysOnTop +ToolWindow +OwnDialogs
Gui %hwnd%: Color, 464646
Gui %hwnd%: Font, cFFFFFF, Consolas
Gui %hwnd%: Add, Button, gthis.test() x231 y208 w93 h39, &Kaydet
Gui %hwnd%: Add, Text, x10 y10 w100 h20, % Name
Gui %hwnd%: Add, Text, x10 y30 w100 h20 hwndhPos, % x ", " y
Gui %hwnd%: Show, % "x" x " y" y " w500 h600", guimiz
WinSet, Transparent, 170, guimiz
WinSet, Region, 0-0 w500 h600 R30-30, guimiz
this.hPos := hPos, this.hwnd := hwnd, this.Name := Name
OnMessage(0x201, this.WM_LBUTTONDOWN.Bind(this))
}
WM_LBUTTONDOWN() {
PostMessage, 0xA1, 2
KeyWait, LButton
WinGetPos, x,y,,, % "ahk_id " this.hwnd
GuiControl, % this.hwnd ":", % this.hPos, % x ", " y
;MsgBox,,, % this.Name, 0.5
}
test(){
msgbox, this is test
}
}