Results 1 to 20 of 20

Thread: [RESOLVED] Un-Subclass a Form

Threaded View

  1. #1

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Arrow [RESOLVED] Un-Subclass a Form

    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....

    vb Code:
    1. Public Sub SubClassHwnd(ByVal hWnd As Long)
    2.     'START SUBCLASSING
    3.     mlPrevWndProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)
    4. End Sub
    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:
    1. Case WM_DESTROY
    2.             'REMOVE SUBCLASSING WHEN FORM IS DESTROYED (FORM1 UNLOADED)
    3.             WindowProc = CallWindowProc(mlPrevWndProc, hWnd, Msg, wParam, lParam)
    4.             UnSubClassHwnd Form1.hWnd
    5.             Exit Function
    vb Code:
    1. Public Sub UnSubClassHwnd(ByVal hWnd As Long)
    2.     'END SUBCLASSING
    3.     Call SetWindowLong(hWnd, GWL_WNDPROC, mlPrevWndProc)
    4. End Sub

    I can not just call the UnSubClassHwnd procedure upon the button click so what am i missing?

    Any suggestions?

    Thanks
    Last edited by RobDog888; Mar 10th, 2007 at 11:29 PM.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width