Small sample of bridging from functions to classes. Emphasis was on minimizing implementation code for each class.
Class cChildWindow Guid$("{a48a64eb-d92d-479a-ab26-f37a0153e1c5}") Common
Instance hWnd_ As Dword: ' Handle to window
Instance bridge_ As iMessageBridge: ' Message bridge
Interface iMessage Guid$("{2e0e23cf-6e19-4a88-a33c-2cca8397778f}")
Inherit IUnknown
Property Get HWnd() As Long
Property = hWnd_: ' Return window handle
End Property
Method Proc( ByVal wMsg As Dword, ByVal wParam As Long, ByVal lParam As Long, ByRef ret As Long) As Long
Method = -1: ' Default to handled, ret is already 0
Select Case wMsg
Case %WM_Char: If InStr("0123456789", Chr$(wparam))>0 Then Exit Method: ' Suppress numeric entry, ret=0 EXAMPLE
End Select
Method = 0: ' If we exit this way, we didn't handle message
End Method
End Interface
Interface iChildWindow Guid$("{6856addd-9a21-440b-b360-4337b4cf182a}")
Inherit IUnknown
Method SetWindow( hParent As Dword, ByVal l As Long, ByVal t As Long, ByVal w As Long, ByVal h As Long )
Dim vmsg As iMessage: ' This function belongs in the Create method, but PB doesn't support parameterized constructors
hWnd_ = Me.CreateChildWindow( hParent, l, t, w, h ): ' Implementation Specific
vmsg = Me
bridge_ = NewMessageBridge( vmsg ): ' hWnd needs to be valid before this is called
End Method
End Interface
The three bold/italic lines above are implementation specific. Replace them with code of your choice. The rest of the bolded text is also implementation specific but you should simply replace them with your values. For example replace cChildWindow Guid$("{a48a64eb-d92d-479a-ab26-f37a0153e1c5}")
with the name of your class and guid.