MFC Overview
-
Having created lots of mickey mouse applications using the wizard, as well as trying out examples in the half dozen fat books I have bought, I am nowhere nearer to understanding the what where and how of how to structure an application. I have nice examples of how to output text in a window, how to draw lines, OR how to read in data from the keyboard, but there seems to be Jack Beep around on how to tie any two of these obviously mind-boggling concepts into the same app. What I want to do is read and process data from a binary file (done, that was easy) and then use some of that data (actually x-y positional data) to write shapes to the window. Any help or ideas much appreciated.:confused: E Dyot
-
Having created lots of mickey mouse applications using the wizard, as well as trying out examples in the half dozen fat books I have bought, I am nowhere nearer to understanding the what where and how of how to structure an application. I have nice examples of how to output text in a window, how to draw lines, OR how to read in data from the keyboard, but there seems to be Jack Beep around on how to tie any two of these obviously mind-boggling concepts into the same app. What I want to do is read and process data from a binary file (done, that was easy) and then use some of that data (actually x-y positional data) to write shapes to the window. Any help or ideas much appreciated.:confused: E Dyot
This sounds like a good job for an SDI application. Read the data into the document. The document then notifies the view that new data needs to be rendered. In in the view, ask the document for the new data and render it accordingly. Look at the MSDN's Scribble tutorial.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
-
This sounds like a good job for an SDI application. Read the data into the document. The document then notifies the view that new data needs to be rendered. In in the view, ask the document for the new data and render it accordingly. Look at the MSDN's Scribble tutorial.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
E Dyot wrote: Look at the MSDN's Scribble tutorial. Scribble, what a great learning tool. When I started with MFC (had used OWL before) I printed out the entire tutorial, followed it from start to end, and then started adding my own stuff. CP was not around at the time, so I don't think I could have figured out so much about MFC without it.
-
This sounds like a good job for an SDI application. Read the data into the document. The document then notifies the view that new data needs to be rendered. In in the view, ask the document for the new data and render it accordingly. Look at the MSDN's Scribble tutorial.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
"Read the data into the document" - done. Because it's binary, I thought it needed to be read in and processed byte by byte. To do this I wrote a routine : BOOL CMyDoc::OnOpenDocument(LPCTSTR lpszPathName) { if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; // lots of my code to convert various doubles, ulongs, ushorts etc into physical numbers and attributes // // all data processed, ready for display// //Now we're stuck. // } Now, the problem I have is, *how* do I pass the data to - and to *which* routine - in order to paint, say, a box on the screen, using that data? Automatically, i.e. no mouse input, no keyboard input. I don't want to draw using the mouse, and it is not a dead text file that I am reading. The whole concept is an automatic process, in which the user is prompted for a path, and then the application processes a bunch of different files, mostly binary, and then *should* output a simple graphical representation of some mechanical items on the window, based on the data that was processed. E Dyot
-
"Read the data into the document" - done. Because it's binary, I thought it needed to be read in and processed byte by byte. To do this I wrote a routine : BOOL CMyDoc::OnOpenDocument(LPCTSTR lpszPathName) { if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; // lots of my code to convert various doubles, ulongs, ushorts etc into physical numbers and attributes // // all data processed, ready for display// //Now we're stuck. // } Now, the problem I have is, *how* do I pass the data to - and to *which* routine - in order to paint, say, a box on the screen, using that data? Automatically, i.e. no mouse input, no keyboard input. I don't want to draw using the mouse, and it is not a dead text file that I am reading. The whole concept is an automatic process, in which the user is prompted for a path, and then the application processes a bunch of different files, mostly binary, and then *should* output a simple graphical representation of some mechanical items on the window, based on the data that was processed. E Dyot
E Dyot wrote: Now, the problem I have is, *how* do I pass the data to - and to *which* routine - in order to paint, say, a box on the screen, using that data? Handle the OnDraw function in your CView based class. From OnDraw, you can call GetDocument() to retrieve a pointer to your document.
CMyView::OnDraw(CDC* pDC)
{
// Grab the doc
CMyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);// Get the doc data
pDoc->GetDataUsedToDrawStuff();// You can use clipping functions to help eliminate unnecessary drawing
if (pDC->RectVisible(blah))// Draw as you see fit using the various CDC GDI/drawing functions
pDC->SelectObject(brush/font/pen);
pDC->FrameRect(blah);
pDC->TextOut(blah);
etc...
}:suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!