Re: OnActivateView problem
I have a class derived from CView, say CViewA. I have controls in a
CDialogBar. when the view CViewA is activated I enable the button on
the dialogbar and when it is deactivated I disable the buttons on the
dialog bar. But i donot want the buttons to enable or disable when
there is switch between same type of view. This is creating refreshing
First the CViewA, OnActivateView is called with bActivate equal to
False, then the same function is called with bActivate equals to true.
This is not the way to handle this. You should be handling your
enable/disable code the same way it is handled for regular MFC toolbar
However, according to your requirements, I don't see how this is a problem.
If OnActivateView is called with bActivate == FALSE, then you should disable
the controls. And if it's called again with bActivate == TRUE, then you
should enable the controls. The result could be a flicker but it seems like
the result is exactly what you're asking for.
If the problem that you mean some of the same type of views should enable
the controls while others should not, simply have some way to determine if
the current view should enable the controls and then check that when
bActivate == TRUE.
But CView retunns CViewA when its bActivate==false. So in the
OnActivateView function when bActivate==False, I donot I know which
View is getting active, so that if the same view is getting active,
then i donot do enabling/disabling of buttons ?
If bActivate == FALSE, then no view is getting activated *at that point*.
Why not just wait until bActivate == TRUE?