I am trying to subclass a CWnd class1,not just a control from another CWnd class2 to take over paint messages among others. First attempts failed because CWnd::SubclassWindow() requires the HWND be detached from the CWnd class. (can't do because then class1 will no longer have a valid HWND) Have had better success with the following:
OldProc = SetWindowLong(hwnd,GWL_WNDPROC,fn);
where hwnd= the handle of the windows to subclass
and fn = the address of the new message handler.
Now for the problem: the new message handler (fn) is
a function in a class also. (a class trying to subclass another class) class2::fn actually does get called however the "this" point is invalid, so no member variables are accessible. The "this" pointer passed to class2::fn apparently is the class1::m_hWnd of the original CWnd.
My question is 2 part; first is this a valid approch or is there an easier way of doing this ( or is this posible). Second (vc++ question) how do you obtain a "this" pointer for a class. I can think of a few other needs. mainly C/asm functions calling a C++ class function. thx!