-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathclass_Subclass.ahk
54 lines (49 loc) · 1.24 KB
/
class_Subclass.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
/*
Tested On Autohotkey_L version 1.1.13.00 U32
Author Nick McCoy (Ronins)
Initial Release Date May 6, 2014
Version Release Date May 6, 2014
Version 1.0
*/
Class Subclass
{
__New()
{
return false
}
AddListener(hWnd, Message, Function)
{
this.hWnd[Message] := Function
this.DispatchPointer := RegisterCallback("Subclass_Dispatch")
return, DllCall("Comctl32.dll\SetWindowSubclass", "int", hWnd, "int", this.DispatchPointer, "int", hWnd, "int", 0)
}
RemoveListener(hWnd, Message)
{
if(this.hWnd[Message]=-1 || !IsObject(this.hWnd))
return, false
this.hWnd[Message] := -1
Dummy := 0
For key, value in this.hWnd
if(this.hWnd[key]!=-1)
Dummy++
if(Dummy)
return true
this.hWnd := ""
return DllCall("Comctl32.dll\RemoveWindowSubclass", "int", hWnd, "int", this.DispatchPointer, "int", hWnd)
}
GetFunction(Hwnd, Message)
{
if(this.hWnd[Message])
return this.hWnd[Message]
Return 0
}
}
Subclass_Dispatch(Hwnd, Message, wParam, lParam, IdSubclass, RefData)
{
Function := Subclass.GetFunction(Hwnd, Message)
if(Function = -1)
Exit
If(Function)
Function.(Hwnd, Message, wParam, lParam)
Return DllCall("Comctl32.dll\DefSubclassProc", "Ptr", Hwnd, "UInt", Message, "Ptr", wParam, "Ptr", lParam)
}