Results 1 to 3 of 3

Thread: new in Subcalssing

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 1999
    Location
    Montreal
    Posts
    59
    in form i have
    i allway's get GPF !!! hyw ?

    ---
    Private Sub Form_Load()
    hook = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf WindProc)
    End Sub

    Private Sub Form_Unload(Cancel As Integer)
    SetWindowLong Me.hwnd, GWL_WNDPROC, hook
    hook = 0
    End Sub
    -------
    module i have :
    --------
    Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Form1.Caption = wMsg
    WindProc = CallWindowProc(hook , hwnd&, wMsg&, wParam&, lParam&)
    End Function

  2. #2
    Guest
    I don't have any subclassing exsamples on me right now, but at first glanse it looks correct.
    However if you terminate a program, by pressing the stop button in VB, then the Form_Unload event won't be raised, and you'll get an error and a crash.

    You must therefore always unhook everything manually before you close your program.

    Also when using vb, there are problems asociated with stepping through code on a form, that is subclassed.

  3. #3
    New Member
    Join Date
    Mar 2001
    Location
    Wales, UK
    Posts
    4
    Have you placed Const GWL_WNDPROC = -4 at the top of you code signifying a constant.
    If you have then check the return value in hook. It should be the address of the windows event handler function. If you get 0 then something obviously has gone wrong.
    Apart from this your code is correct. I know this because I am using subclassing at the moment. If there are any particular bugs etc you come across when using subclassing or you need more help(i'll try to help anyway) then please emil me on mfesteba:yahoo.co.uk
    MAD CODER

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