Re: OnActivateView problem
"Kuenga" <sagkumar@gmail.com> wrote in message
news:1a27cd53-04f6-4e73-8786-d0cf72ee83f5@i12g2000prf.googlegroups.com...
On Mar 5, 8:48 am, Kuenga <sagku...@gmail.com> wrote:
Thanks Jonathan for your time..I had tried that way before but it
didnot solve my problem.
I have a ListBox Control on the dialog bar, which I cannot handle like
toolbars.
My document is same but different views. So when different views of
the same document is being switched, I donot want to disable the
buttons. But in the OnActivateView function, when bActivate == FALSE,
if i write the following code
CMainFrame *frame = (CMainFrame *)AfxGetApp()->GetMainWnd();
CMDIChildWnd* pActiveChildFrame = frame->MDIGetActive();
CView* view = pActiveChildFrame->GetActiveView();
it gives me the view that is getting deactivated. Not the view that is
getting activated.
If in the OnActivateView when bActivate == FALSE, i get the view which
is being activated then I can put the following check
if(bActivate==false && !(view->IsKindOf(RUNTIME_CLASS(CViewA)))
then enable the buttons. And my problem will be solved ..
So my question is in OnActivateView function when bActivate==false,
how do I know which view is getting active ?- Hide quoted text -
- Show quoted text -
Is there any work around for this problem ?
Why is this a problem? When bActivate is false your code should return a
pointer to the view being deactivated, that's why bActivate is false. One
question would be why are you going through all those hoops to get a pointer
to the view when it is being passed to OnActivateView?
void CViewA::OnActivateView( BOOL bActivate, CView* pActivateView, CView*
pDeactiveView )
{
// Is it just because the application regained focus (from user
switching applications)
if ( pActivateView == pDeactiveView )
return; // Yep, don't need to do anything...
// Do we need to disable anything...
if ( bActivate == FALSE )
{
// Maybe, let's do some more checking...
if ( pDeactivateView == NULL )
{
// Not sure if this would actually happen but I suppose it could
if the
// application was being shutdown with only the one view open...
// do whatever makes since in your app here...
}
else if ( !(pActivateView->IsKindOf(RUNTIME_CLASS(CViewA))) &&
(pDeactivateView->IsKindOf(RUNTIME_CLASS(CViewA))) )
{
// Yep, new view is not derived from CViewA but the old one was
so disable the stuff...
}
}
else
{
if ( (pActivateView->IsKindOf(RUNTIME_CLASS(CViewA))) )
{
// Activating a CViewA derived class, enable the dialog bar
stuff...
}
}
}
This is off the top of me head so you will need to adjust it to your
needs...
--
============
Frank Hickman
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.