September 30th, 2013, 03:10 PM
CDockablePane messages in MFC document/view architecture (good programming practices)
I am developing a small MFC program, and I'm obsessed with good programming practices.
I would like to know how to manage messages between windows in SDI application in the right way on a document / view architecture.
Below I will outline practical case in which I have encountered a problem. The following image is a screenshot of my SDI application generated with visual studio wizard.
The three main classes generated by visual studio wizard are:
The window that I have numbered as one is a Class CCameraCalibrationView, and is easy to access the document linked to by the function GetDocument() and modify it in response to user interaction with the window.
pDocTemplate = new CSingleDocTemplate(
RUNTIME_CLASS(CMainFrame), // Ventana de marco SDI principal
So it is just as easy to call the function UpdateAllViews (CView * pSender, LPARAM lHint = 0L, CObject * pHint = NULL) after modifying the document to refresh the view CCameraCalibrationView class.
class CCameraCalibrationView : public CView
protected: // Crear sólo a partir de serialización
CCameraCalibrationDoc* GetDocument() const;
UpdateAllViews only modifies CView inherited classes that are part of the document template in the case of my application is CCameraCalibrationView (and on a SDI application I think I can only have one view linked to the document). The problem is that my CDockablePane controls (2 and 3 in the screenshot) that should be able to modify the document in response to the user and should be updated as CCameraCalibrationView to the modification of the document.
I dont know how to do it, respecting the document / view architecture and program it in an elegant way.
I can only think in generate custom windows messages from DockablePanes in respond to user inputs and send it to the CMainFrame, cath it from the MainFrame and change the document from here and redistribuite the message to all views including the CDockablePanes. it's rigth? it's smart?
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!