UpdateAllViews (...) - a trivial question
-
Hello, MSDN says void UpdateAllViews( CView* pSender, LPARAM lHint = 0L, CObject* pHint = NULL ); Now this call is in my menuclick event in the doc cpp. Lets say a view class called CViewTwo generated the click. I want view1 to reflect the changes, but not sending class (the CViewTwo class). I think if I dont have a NULL argument, it excludes the update of pSender. I am not sure exactly what will go into CView* pSender. How do I get the pointer to my sending viewclass from the doc click event? Thanks so much!
-
Hello, MSDN says void UpdateAllViews( CView* pSender, LPARAM lHint = 0L, CObject* pHint = NULL ); Now this call is in my menuclick event in the doc cpp. Lets say a view class called CViewTwo generated the click. I want view1 to reflect the changes, but not sending class (the CViewTwo class). I think if I dont have a NULL argument, it excludes the update of pSender. I am not sure exactly what will go into CView* pSender. How do I get the pointer to my sending viewclass from the doc click event? Thanks so much!
If your doc handles the click, there is no sending view. You need to handle the click in the view, not the doc, to do what you're asking.
-
Hello, MSDN says void UpdateAllViews( CView* pSender, LPARAM lHint = 0L, CObject* pHint = NULL ); Now this call is in my menuclick event in the doc cpp. Lets say a view class called CViewTwo generated the click. I want view1 to reflect the changes, but not sending class (the CViewTwo class). I think if I dont have a NULL argument, it excludes the update of pSender. I am not sure exactly what will go into CView* pSender. How do I get the pointer to my sending viewclass from the doc click event? Thanks so much!
-
Hello, MSDN says void UpdateAllViews( CView* pSender, LPARAM lHint = 0L, CObject* pHint = NULL ); Now this call is in my menuclick event in the doc cpp. Lets say a view class called CViewTwo generated the click. I want view1 to reflect the changes, but not sending class (the CViewTwo class). I think if I dont have a NULL argument, it excludes the update of pSender. I am not sure exactly what will go into CView* pSender. How do I get the pointer to my sending viewclass from the doc click event? Thanks so much!
jim is right to do your task the calling should be in view it can be done in following way suppose your classes are CMyDoc CView1 CView2 now in CView2 class on handler of the click event u can do this CMyDoc *pDoc=this->GetDocument(); pDoc->UpdateAllViews(this);//passing this as argument excludes the view from which the function is called pDoc->UpdateAllViews(NULL);//updates all views attached to document including the view from which the function is called(in this case view2) surbinsho
-
jim is right to do your task the calling should be in view it can be done in following way suppose your classes are CMyDoc CView1 CView2 now in CView2 class on handler of the click event u can do this CMyDoc *pDoc=this->GetDocument(); pDoc->UpdateAllViews(this);//passing this as argument excludes the view from which the function is called pDoc->UpdateAllViews(NULL);//updates all views attached to document including the view from which the function is called(in this case view2) surbinsho
Thank you so much for the responses. It works well, but I do have to set the controls newvalues by coding the OnUpdate event of the view thats supposed to reflect the changes. I get the doc pointer both in the sending view (to set the new value for the doc variable , as well as in the receiving view where I get the doc pointer in order to access the newly changed value. Thanks, ns