quote:Original post by Oluseyi
Rather than deriving class CustomWindow from Window and then overriding Window::OnStrangeEvent (which must be declared and defined in the base Window class), simply define void OnStrangeEvent and call Window::RegisterMessagehandler(WM_STRANGEEVT, OnStrangeEvent) and get on with life.
I cannot say I agree with this decidedly non-OOP design.
But if it works for you, then all is well.
And no, the OnStrangeEvent doesn't need to be declared in
the base window. The base window doesn't need to know
anything about StrangeEvent at all. What you do is in the
derived class HandleEvent (which is virtual), you add a new
case to dispatch StrangeEvent to OnStrangeEvent. Your new
StrangeWindow adds a new virtual function OnStrangeEvent
and "get on with life". All new classes derived from
StrangeWindow now knows how to handle StrangeEvent.
Maybe I'll write an article on an "alternative" (but more
object-oriented) solution and submit to GameDev.
Premature optimizations can only slow down your project even more.
Edited by - tangentz on February 18, 2002 1:36:32 PM