Announcement

Collapse
No announcement yet.

Subclassing: CallWindowProc using a method?

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

  • Chris Holbrook
    replied
    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...

    Leave a comment:


  • Michael Mattias
    replied
    Um, so what is the problem?

    Calll me overly optimistic, but it sure looks like you have everything managed in the subclass procedure.

    Leave a comment:


  • Chris Holbrook
    replied
    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

    Leave a comment:


  • Michael Mattias
    replied
    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...........
    ???

    Leave a comment:


  • Chris Holbrook
    replied
    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.

    Leave a comment:


  • Michael Mattias
    replied
    Call me simple, but why not just have the subclass proc call (right word?) the method?

    Leave a comment:


  • Chris Holbrook
    replied
    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.

    Leave a comment:


  • Edwin Knoppert
    replied
    Something like?..

    fptr = @pUnk[offset]

    Leave a comment:


  • Chris Holbrook
    replied
    Thanks Bob.

    Leave a comment:


  • Bob Zale
    replied
    No. A METHOD is not a function. Different conventions.

    Leave a comment:


  • Chris Holbrook
    started a topic Subclassing: CallWindowProc using a method?

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