`
OOP: Subclassing and passing class reference via window property 2004-07-29 -- Jens Weiermann Newsgroups: sv.clarion.suggestions Jonathan Kay wrote: > Currently writing a generic class for subclassing is painful; you have to > maintain the address of the class in a QUEUE so you can call virtual methods > from within the sub-classed procedure. And since this has to be module level > data you've got to synchronize it too. I've found a way to make this easier. I'm storing the address of my Clarion class instance in a window property of the sublclassed window (via the SetProp api). This way, I can reference assign that address to a Clarion variable again, like this (part of the WindowProc of the sublassed window): DATA SomeReference &MyClass CODE SomeReference &= (GetProp(hWnd, "MyClassUniqueString")) case Msg of WM_PAINT SomeReference.OnPaint(...) of WM_SETFOCUS SomeReference.OnSetFocus(...) of WM_KILLFOCUS SomeReference.OnKillFocus(...) end I've started rewriting my Sys* product series using this technique and haven't experienced any problems yet... HTH! Jens -- Jens Weiermann solid software http://www.solidsoftware.de Printed November 21, 2024, 12:09 pm This article has been viewed/printed 35395 times. Google search has resulted in 11 hits on this article since January 25, 2004. |