-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathExtControl.cls
More file actions
148 lines (141 loc) · 3.62 KB
/
Copy pathExtControl.cls
File metadata and controls
148 lines (141 loc) · 3.62 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "ExtControl"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Public WithEvents mycontrol As VBControlExtender
Attribute mycontrol.VB_VarHelpID = -1
Dim another As Object
Dim myname$, mytypedef$
Dim Callback As GuiM2000
Dim mIndex As Long
Friend Property Get GetCallBack() As GuiM2000
Set GetCallBack = Callback
End Property
Public Property Get index() As Long
index = mIndex
End Property
Friend Property Let index(ByVal RHS As Long)
mIndex = RHS
End Property
Friend Property Get ControlName() As String
ControlName = myname
End Property
Friend Property Get TypeDef() As String
TypeDef = mytypedef$
End Property
Friend Sub Attach(b As Control, aName$, typ$, mform As GuiM2000, Optional indx As Long = -1)
Err.Clear
On Error Resume Next
Set mycontrol = b
If Err.Number Then
Err.Clear
Set another = b
End If
mIndex = indx
Set Callback = mform
myname$ = aName$
End Sub
Property Get FixEvent() As Boolean
FixEvent = mycontrol Is Nothing
End Property
Property Get Value() As Object
Attribute Value.VB_UserMemId = 0
On Error Resume Next
If Not another Is Nothing Then
Set Value = another
Else
Set Value = mycontrol
End If
End Property
Public Sub deconstruct()
Set Callback = Nothing
Set mycontrol = Nothing
Set another = Nothing
End Sub
Private Sub mycontrol_ObjectEvent(Info As EventInfo)
Dim Values(), M As Long, uk1 As Object
'Debug.Print Info.Name, mycontrol.Name
If LCase(Info.Name) = "lostfocus" Or LCase(Info.Name) = "lostfocus1" Then
If mycontrol.enabled And mycontrol.Visible Then
Callback.LastActive = mycontrol.Name 'myname$
Else
If Callback.LastActive = vbNullString Then
Callback.LastActive = "gList2"
End If
On Error Resume Next
If Callback.Controls(Callback.LastActive).Visible Then
Dim a As Object
Set a = Callback.Controls(Callback.LastActive)
If a Is Nothing Then
Callback.LastActive = ""
ElseIf a.enabled Then
a.SetFocus
End If
End If
End If
End If
If Info.EventParameters.Count > 0 Then
ReDim Values(0 To Info.EventParameters.Count)
Dim evinf As EventParameter
M = 0
'Dim check As Variant
For Each evinf In Info.EventParameters
On Error GoTo 100
Set check = evinf
If MemLong(MemLong(VarPtr(check) + 8) + 24) = 0 Then
Err.Clear
Values(M) = "Error"
Else
If MyIsObject(evinf.Value) Then
Set Values(M) = evinf.Value
Else
Values(M) = evinf.Value
End If
End If
100
If Err Then
Err.Clear
Values(M) = "Error"
End If
M = M + 1
Next evinf
If mIndex <> -1 Then
Callback.CallbackNow myname$ + "." + Info.Name + "(" & mIndex & ")", Values()
Else
Callback.CallbackNow myname$ + "." + Info.Name + "()", Values()
End If
On Error Resume Next
With Info.EventParameters
For M = M - 1 To 0
If IsObject(Values(M)) Then
If Not .item(M).Value Is Values(M) Then
Set check = .item(M)
Set check.Value = Values(M)
End If
Err.Clear
Else
.item(M).Value = Values(M)
End If
Next M
End With
ElseIf mIndex <> -1 Then
Callback.Callback myname$ + "." + Info.Name + "(" & mIndex & ")"
Else
Callback.Callback myname$ + "." + Info.Name + "()"
End If
End Sub
Public Property Let Default(RHS)
On Error Resume Next
If Not Callback Is Nothing Then
If CBool(RHS) Then Callback.Default = mycontrol.Name
End If
End Property