I am subclassing a form in my project for certain reasons. I now have the need to give the ability to unsubclass it. Mostly for reducing used resources.
I have the usual subclassing start procedure....
But in the WindowProc I have it unsubclassing upon the WM_DESTROY message. But I need to simulate what its doing in there but upon a button click and not the ending of the program.vb Code:
Public Sub SubClassHwnd(ByVal hWnd As Long) 'START SUBCLASSING mlPrevWndProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc) End Sub
vb Code:
Case WM_DESTROY 'REMOVE SUBCLASSING WHEN FORM IS DESTROYED (FORM1 UNLOADED) WindowProc = CallWindowProc(mlPrevWndProc, hWnd, Msg, wParam, lParam) UnSubClassHwnd Form1.hWnd Exit Functionvb Code:
Public Sub UnSubClassHwnd(ByVal hWnd As Long) 'END SUBCLASSING Call SetWindowLong(hWnd, GWL_WNDPROC, mlPrevWndProc) End Sub
I can not just call the UnSubClassHwnd procedure upon the button click so what am i missing?
Any suggestions?
Thanks





Reply With Quote