Re: deriving helper class from CWnd
"jbreher" <jbreher@discussions.microsoft.com> ha scritto nel messaggio
news:1E1EC48A-C610-4071-9848-7DF061FA919E@microsoft.com...
I have a simple working MFC application. All logic is within the main
CDialog. I want to refactor the functional aspects out of this CDialog
into
an 'engine' class, leaving only the UI aspects in the CDialog-derived
class.
I have successfully moved many members from the CDialog to the new engine
class. My problem is exhibited in moving a timer from the CDialog to the
new
engine class.
I think you may do something like this:
in your engine class, you can just expose a public method to handle OnTimer
events, e.g.
class Engine
{
public:
...
// Process time event
void OnTimer();
...
};
then, in your CDialog derived class, in the OnTimer message handler body,
you can call the Engine::OnTimer method, e.g.
void <your dialog or window>::OnTimer(UINT nIDEvent)
{
...
// Route call to engine OnTimer:
m_pEngine->OnTimer();
...
}
HTH,
Giovanni