Messages Between CFormViews
-
I have multiple CFormView windows in a MFC Doc/View application that uses a Multiple View CSplitterWnd based class to switch out views in two of the panes. To control the app, I need to pass messages between views. I have a central control class embedded in the app's CDocument derived class that controls all the views (and maintains access to pointers to the CFormView window object via the Splitter based class). Anyway, to the question - Should I: 1) Pass messages to the CFormView class DIRECTLY via a "virtual int SendViewMessage(...)" method since I have direct access to the CFormView based Objects; or 2) Should I post the messages via normal Windows Message (RegisterWindowMessage) to the CFormView and let the CFormView derived classes hanlde via Message Map. I'm not sure of the consequences of the DIRECT approach as far as the MFC Doc/View framework is concerned. I see CDocument and CView calling methods directly in MFC rather than passing messages. Is there a rule on this somewhere ???? Or, since all Doc/View framework in the same thread, does this matter at all ???? Any info would be appreciated !!!!!! Thanks, John
-
I have multiple CFormView windows in a MFC Doc/View application that uses a Multiple View CSplitterWnd based class to switch out views in two of the panes. To control the app, I need to pass messages between views. I have a central control class embedded in the app's CDocument derived class that controls all the views (and maintains access to pointers to the CFormView window object via the Splitter based class). Anyway, to the question - Should I: 1) Pass messages to the CFormView class DIRECTLY via a "virtual int SendViewMessage(...)" method since I have direct access to the CFormView based Objects; or 2) Should I post the messages via normal Windows Message (RegisterWindowMessage) to the CFormView and let the CFormView derived classes hanlde via Message Map. I'm not sure of the consequences of the DIRECT approach as far as the MFC Doc/View framework is concerned. I see CDocument and CView calling methods directly in MFC rather than passing messages. Is there a rule on this somewhere ???? Or, since all Doc/View framework in the same thread, does this matter at all ???? Any info would be appreciated !!!!!! Thanks, John
John Gilbert wrote: I'm not sure of the consequences of the DIRECT approach as far as the MFC Doc/View framework is concerned. I see CDocument and CView calling methods directly in MFC rather than passing messages There are none. You're free to invent any mechanism of data exchange between views. Or - you can use existing one - the CDocument::UpdateAllViews which gives you enough flexibility. I'd go for UpdateAllViews first, then for custom virtual function and if this doesn't fit your model, for Windows messages. Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
-
John Gilbert wrote: I'm not sure of the consequences of the DIRECT approach as far as the MFC Doc/View framework is concerned. I see CDocument and CView calling methods directly in MFC rather than passing messages There are none. You're free to invent any mechanism of data exchange between views. Or - you can use existing one - the CDocument::UpdateAllViews which gives you enough flexibility. I'd go for UpdateAllViews first, then for custom virtual function and if this doesn't fit your model, for Windows messages. Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
Thanks, UpdateAllViews() will probably do the job. I did not realize that UpdateAllViews() has two user type parameters that I can use to pass my control data. Also, someone reminded me that the CFormView Object and the actual Window are two different things. So a "Direct" call (as I was calling it) goes to the object which will eventually pass messages to the attached window anyway. I knew that :zzz:, but was getting lost in the Doc/View world :confused: . Thanks for your time to respond !!!!! :) John