How to use the Document / View architecture in MFC

I'm still working on a Data Acquisition program in MFC, and I'm stuck with working with the Document / View architecture. Basically, I want my application to have a couple of windows. One is used to display video recorded at a high speed of the camera, and the other has a graph displaying data from the DAQ system, and possibly another control to configure the camera and DAQ, etc.

So, actually I have a lot of weak windows, each of which shows a piece of data, usually from a different source. Now, after going through the Application Wizards, I got confused in the Doc / View stuff, and although I can turn it off, it doesn't technically work. Now, aside, I tried to open modeless Dialogs and FormViews without success. Basically I just can't figure out how to open a new View, the documentation is not very useful. I managed to open the Modal plotting dialog from the Button command of the ribbon, and I mark this as successful, but not quite what I need.

So, does anyone have a useful idea on installing my application in the Doc / View architecture or opening a model or FormView dialog box from another application. I have to say that I use Microsoft Visual Studio 2010 and I use MFC and C ++.

EDIT:

So, I went with MDI and will have one document that processes all the data that will be shown. Now I am stuck on how to create some windows that I want. I trimmed CFormView to be a graph. The view of the document, and I'm trying to create this window when I press the menu button. I was able to do this using a modal dialog, for example:

void CDAQUniversalApp::OnScopebtn() { // TODO: Add your command handler code here CScopeDlg dlg = new CScopeDlg(); //CScopeDlg is Subclass of CDialog dlg.DoModal(); } 

This worked, but not what I want, so I tried this and it didn't work at all:

  m_pScopeTemplate = new CMultiDocTemplate( IDD_SCOPEFORMVIEW, RUNTIME_CLASS(CDAQUniversalDoc), RUNTIME_CLASS(CMDIChildWnd), RUNTIME_CLASS(CScopeFormView)); //Subclass of CFormView if (!m_pScopeTemplate) return FALSE; void CDAQUniversalApp::OnScopebtn() { // TODO: Add your command handler code here CMDIChildWnd* pFrame = NULL; pFrame = DYNAMIC_DOWNCAST(CMDIChildWnd, CWnd::GetActiveWindow()); CMDIChildWnd *pScopeFrame = (CMDIChildWnd*)m_pScopeTemplate->CreateNewFrame(pFrame->GetActiveDocument(), NULL); if (pScopeFrame == NULL) return; m_pScopeTemplate->InitialUpdateFrame(pScopeFrame, pFrame->GetActiveDocument(), TRUE); } 

It just raises an unhandled exception. I really just sketched my way to this issue, discovering various largely useless sections of the documentation code and changing it to what I thought was necessary.

+4
source share
1 answer

Your different windows (for video display, data display and configuration) actually represent all the views (different presentation classes) for one document that manages the data (provided that DAQ works with video data?).

I suggest you pack the application into an MDI application, thus having a main window with all these different views as subwindows. This way, you have several views for one document (or even several documents in MDI).

MFC can be painful if your application does not conform to the classical document / presentation architecture (e.g. Word), but I think that would be the best way to fit your application into this structure.

+3
source

All Articles