'Control Class that handles the basic events/messages of all control windows
'Controls, like TextBox and CommandButton, use this as a base class and extend it to implement thier own msg and events.
Using WinBase 'API's Declares,in basic Syntax.
Using User32 'API's Declares,in basic Syntax.
Using GDI32 'API's Declares,in basic Syntax.
Using Kernel32 'API's Declares,in basic Syntax.
Class Control
Protected lastMessage As Long
Protected m_top As Integer
Protected m_left As Integer
Protected m_width As Integer
Protected m_height As Integer
Protected originalProc As Long
Protected p_hwnd As Long
Protected m_hwnd As Long
Protected beforeHwnd As Long
Protected resourceID As Long
Public IgnoreFocus As Boolean
Public EventMsgGotFocus As Long
Public EventMsgLostFocus As Long
Public EventMsgMouseMove As Long
Public EventMsgMouseUp As Long
Public EventMsgMouseDown As Long
Public EventMsgKeyPress As Long
Public EventMsgKeyDown As Long
Public EventMsgKeyUp As Long
Public m_Tag As Long
Public ObjectPtr As Long
Public IndexNumber As Integer
Private Function OnGotFocus()
'if EventMsgGotFocus is 0 then theres nothing to do
If EventMsgGotFocus=0 Then
'so return.
Exit Function
End If
'ObjectPtr is > 0 if this control is used in a class.
If ObjectPtr=0 Then
'index number used for control arrays
If IndexNumber>=0 Then
'declare a variable as a function so to say
Dim funcptr As Function (iii As Integer)
'set the address of the function
funcptr=EventMsgGotFocus
'call the function
funcptr(IndexNumber)
Else
Dim funcptr As Function()
funcptr=EventMsgGotFocus
funcptr()
End If
Else
If IndexNumber>0 Then
Dim funcptr As Function (ooo As Long)
funcptr=EventMsgGotFocus
funcptr(ObjectPtr)
Else
Dim funcptr As Function (ooo As Long, iii As Integer)
funcptr=EventMsgGotFocus
funcptr(ObjectPtr,IndexNumber)
End If
End If
End Function
'...... more code
Public Property Set Left(pos As Integer)
m_left=pos
MoveWindow(m_hwnd,m_left,m_top,m_width,m_height,True)
End Property
Public Property Get Left() As Integer
Left=m_left
End Property
End Class