-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathGuiCtl.ahk
104 lines (90 loc) · 1.79 KB
/
GuiCtl.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
class GuiCtl
{
static Type := ""
__New(gui, args*)
{
Gui, %gui%:+LastFoundExist
if !WinExist()
throw Exception("GUI does not exist.", -1, gui)
CtlType := this.Type ? this.Type : ObjRemoveAt(args, 1)
options := args[1], text := args[2]
Gui, %gui%:Add, %CtlType%, %options% HwndhCtl, %text%
this.__Handle := hCtl + 0
this.__Gui := gui
}
Handle {
get {
return this.__Handle + 0
}
set {
throw Exception("This property is read-only", -1, "Handle")
}
}
Gui {
get {
return this.__Gui
}
set {
throw Exception("This property is read-only", -1, "Gui")
}
}
Value {
set {
gui := this.Gui, hCtl := this.Handle
GuiControl, %gui%:, %hCtl%, %value%
return value
}
get {
gui := this.Gui, hCtl := this.Handle
GuiControlGet, value, %gui%:, %hCtl%
return value
}
}
Pos[arg:=""] {
get {
gui := this.Gui, hCtl := this.Handle
GuiControlGet, pos, %gui%:Pos, %hCtl%
return arg ? pos%arg% : { X:posX, Y:posY, W:posW, H:posH }
}
}
Listener {
set {
gui := this.Gui, hCtl := this.Handle
if value
{
if IsObject(value)
GuiControl, %gui%:+g, %hCtl%, %value%
else
GuiControl, %gui%:+g%value%, %hCtl%
}
else
GuiControl, %gui%:-g, %hCtl%
return value
}
}
SetFocus()
{
gui := this.Gui, hCtl := this.Handle
GuiControl, %gui%:Focus, %hCtl%
}
Move(X:="", Y:="", W:="", H:="", redraw:=false)
{
gui := this.Gui
hCtl := this.Handle
pos := ""
Loop, Parse, % "xywh"
if (%A_LoopField% != "")
pos .= " " . A_LoopField . %A_LoopField%
Move := redraw ? "MoveDraw" : "Move"
GuiControl, %gui%:%Move%, %hCtl%, %pos%
}
MoveDraw(X:="", Y:="", W:="", H:="")
{
this.Move(X, Y, W, H, true)
}
Hide(hide:=true)
{
gui := this.Gui, hCtl := this.Handle
GuiControl, %gui%:Hide%hide%, %hCtl%
}
}