Prev: CAnimateCtrl
Next: CDhtmlDialog Charset Problem
From: Kuenga on 4 Mar 2008 01:07 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 problem. First the CViewA, OnActivateView is called with bActivate equal to False, then the same function is called with bActivate equals to true. I used the following code to find which view is getting active:- CMainFrame *frame = (CMainFrame *)AfxGetApp()->GetMainWnd(); CMDIChildWnd* pActiveChildFrame = frame->MDIGetActive(); CView* view = pActiveChildFrame->GetActiveView(); if(bActivate==false && !(view->IsKindOf(RUNTIME_CLASS(CViewA))) //donot disable the buttons.. 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 ? Is this a limitation of CView ?
From: Jonathan Wood on 4 Mar 2008 11:56 Kuenga, >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 > problem. > > 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 buttons. 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? -- Jonathan Wood SoftCircuits Programming http://www.softcircuits.com
From: Kuenga on 4 Mar 2008 22:48 On Mar 4, 9:56 pm, "Jonathan Wood" <jw...(a)softcircuits.com> wrote: > Kuenga, > > >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 > > problem. > > > 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 > buttons. > > 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? > > -- > Jonathan Wood > SoftCircuits Programminghttp://www.softcircuits.com 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 ?
From: Kuenga on 10 Mar 2008 00:19 On Mar 5, 8:48 am, Kuenga <sagku...(a)gmail.com> wrote: > On Mar 4, 9:56 pm, "Jonathan Wood" <jw...(a)softcircuits.com> wrote: > > > > > > > Kuenga, > > > >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 > > > problem. > > > > 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 > > buttons. > > > 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? > > > -- > > Jonathan Wood > > SoftCircuits Programminghttp://www.softcircuits.com > > 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 ?
From: Frank Hickman on 10 Mar 2008 02:27 "Kuenga" <sagkumar(a)gmail.com> wrote in message news:1a27cd53-04f6-4e73-8786-d0cf72ee83f5(a)i12g2000prf.googlegroups.com... On Mar 5, 8:48 am, Kuenga <sagku...(a)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(a)m_ with @ to reply.
|
Pages: 1 Prev: CAnimateCtrl Next: CDhtmlDialog Charset Problem |