Announcement

Collapse
No announcement yet.

Subclassing: CallWindowProc using a method?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Subclassing: CallWindowProc using a method?

    Can I CallWindowProc using a method rather than a function, to subclass a window?

    Compiler doesn't like the "dot" here (error 526 Period not allowed):

    Code:
    GrOldProc = SetWindowLong(hGW, %GWL_WNDPROC, codeptr(me.MethodGrProc)) ' Subclasses Graphic control

  • #2
    No. A METHOD is not a function. Different conventions.

    Comment


    • #3
      Thanks Bob.

      Comment


      • #4
        Something like?..

        fptr = @pUnk[offset]

        hellobasic

        Comment


        • #5
          Edwin, I thought about it but as it happens I have a global array of the class in question so I can just send a message to the subclass function with the index of the class member.

          Comment


          • #6
            Call me simple, but why not just have the subclass proc call (right word?) the method?
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Originally posted by Michael Mattias View Post
              Call me simple, but why not just have the subclass proc call (right word?) the method?
              as there are lots of class members in the array, it has to know which one to call.

              Comment


              • #8
                as there are lots of class members in the array, it has to know which one to call
                ??

                You know the message, and SetWindowLong(hWnd, GWL_USERDATA) can hold all kinds of info re the 'state' of the program and/or main window.
                Code:
                FUNCTION SubClassProc ( hWnd, uMSG...) 
                
                     CASE message_of_interest 
                          My_data =  GetWindowLong (getParent(hWnd), GWL_USERDATA) 
                          SELECT CASE My_data
                             case  1 
                                 Z = object.method_one
                             case  2 
                                 Z = object.method_two
                
                ...
                        FUNCTION= CallWindowProc (dwOldProc, hWnd...........
                ???
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  Originally posted by Michael Mattias View Post
                  ???
                  more like:

                  Code:
                  function WndProc(byval hWnd as dword, byval wMsg as dword, byval wParam as dword, byval lParam as long) as long
                      ....
                    static wlx as long
                      ....
                    select case wMsg
                      case 0 ' special case - the winlet is sending its id
                                ' or -1 if it is no longer selected
                          if hWnd = 0 then
                              select case wparam
                                  case 0
                                      wlx = lparam
                                  case -1
                                      wlx = -1
                              end select
                          end if
                          exit function ' do NOT pass the event on to the classproc
                      '
                      case someothermessage
                          if wlx > -1 then gWL(wlx).someothermethod
                      ....
                  Added: Forgot to say that I'm just calling the function with the first two arguments set to zero. If you prefer, you can use a WM_USER + offset message instead.
                  Last edited by Chris Holbrook; 1 Dec 2008, 04:48 PM. Reason: short attention span

                  Comment


                  • #10
                    Um, so what is the problem?

                    Calll me overly optimistic, but it sure looks like you have everything managed in the subclass procedure.
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      Originally posted by Michael Mattias View Post
                      Um, so what is the problem?
                      The problem was resolved by post #2, q.v. Since then it's just been polite conversation...

                      Comment

                      Working...
                      X