paging formviews
<<Thanks for the response. I essentially did exactly what you suggested. I
modified the SwitchToView() function to check the RUNTIME_CLASS against the
known formviews that I have and based on that I call the appropriate
OnLeaveView() that I created for each view.
…
int OldFormID;
if( pOldActiveView->GetRuntimeClass() == RUNTIME_CLASS(CFirstForm))
{
((CFirstForm*)pOldActiveView)->OnLeaveView();
OldFormID = IDW_FIRST_FORM;
}
else if( pOldActiveView->GetRuntimeClass() ==
RUNTIME_CLASS(CSecondForm))
{
((CSecondForm*)pOldActiveView)->OnLeaveView();
OldFormID = IDW_SECOND_FORM;
}
else if( pOldActiveView->GetRuntimeClass() ==
RUNTIME_CLASS(CThirdForm))
{
((CThirdForm*)pOldActiveView)->OnLeaveView();
OldFormID = IDW_THIRD_FORM;
}>>
PFMJI, but this is *terrible* programming (nothing personal 😉 from an OO
standpoint, and is exactly why Bjarne campaigned against RTTI.
Is there any reason that you don't
1) Have OnLeaveView() be a virtual member function of some intermediate class,
from which the other view classes are derived?
2) Use ::GetWindowWord() to get the value for the first SetWindowWord() (not
shown) at the bottom of your function.
If you use these techniques,
1) You don't have to modify your code every time you add a new kind of view.
2) In fact, you don't need that "if-then-else" on RUNTIME_CLASS at all.
3) You don't need the "OldFormID" stuff at all.