
How to trap a container event within an ActiveX Control
I tried subclassing the container from VB's UserControl. It simply hangs!
I tried subclassing after Form_Load event.
Please tell me, what is wrong with this code.
Is there any other method other than subclassing?
The code is..
In UserContol module.
~~~~~~~~~~~~~~~~~~~~~~~~
SubClass:
mWndProcOrg = SetWindowLong(Parent.hWnd, GWL_WNDPROC, AddressOf SubWndProc)
UnSubclass:
Call SetWindowLong(Parent.hWnd, GWL_WNDPROC, mWndProcOrg)
In BAS module:
~~~~~~~~~~~~~~~~
Public Const WM_SIZE = &H5
Public Const GWL_WNDPROC = (-4)
Public mWndProcOrg As Long
Public Function SubWndProc( _
ByVal hWnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
On Error Resume Next
If uMsg = WM_SIZE Then
Debug.Print "Form Resize ..."
End If
SubWndProc= CallWindowProc(mWndProcOrg, hWnd, _
uMsg, wParam, lParam)
End Sub
Thank you!
Regards,
Jack
Quote:
>You can subclass the container's window and handle those messages.
>--
>Girish Bharadwaj [VC++/MVP].
>Dont send email queries to me directly.Please put
>them on the newsgroups.
>Thank you
>>I am developing an ActiveX Control in VC5. I need to trap container events
>>like WM_SIZE(Form_Resize) within my control.
>>Is there any way to do this?
>>Thanks for any help!
>>Regards,
>>Jack