Re: MDI in MFC, Conceptually

From: Roger Lakner (mmm444_at_adelphia.net)
Date: 02/06/05


Date: Sun, 6 Feb 2005 08:47:49 -0800

Well, its nice to know I'm not too far off base, but I'm still puzzled
by something and it relates to what I alluded to in my original
message. Let me be more specific. A View's access to the Document's
data is through a pointer (say, pDoc). The View uses this pointer to,
in my case, render the BMP file data in a window and this is typically
done in OnDraw using pDC. This is easy (using GDI or GDI+ routines)
for the first file I open. When I open the second file, pDoc now
points to the new file data, the new window renders the second image,
but because pDoc now points to the new data, when the first window
which contained the image from the first file receives the OnUpdate
message, OnDraw renders the image that pDoc now points to, which is
the second image. So now I have the second image in both windows --
not what I want. This behavior makes sense if your App contains two
Views of the same Document (as most of the examples demonstrate), but
it seems to me that MFC is not good when you want to display multiple
documents simultaneously. Or am I missing something?

Roger

"Frank Hickman [MVP]" <fhickman_NOSP@M_noblesoft.com> wrote in message
news:uwj6iE$CFHA.328@tk2msftngp13.phx.gbl...
> "Roger Lakner" <mmm444@adelphia.net> wrote in message
> news:8oidncFitduK-pjfRVn-sw@adelphia.com...
>> This is what I understand the way MDI works in the MFC framework:
>> the wizard builds you a View class, Main and Child frame classes,
>> the App class, and a Document class. These classes represent types.
>> And I can have multiple instances of each type. For example,
>> multiple documents open simultaneously or multiple views of a
>> document's data open simultaneously. If I want to have my App work
>> with multiple document types or multiple View types, I realize I
>> need to create a new Document class or a new View class to manage
>> these other types. Most of the MDI sample applications in the
>> documentation and in Prosise's book show how to implement different
>> View types for a single Document type. And there are a couple of
>> examples implementing multiple Document types. And, once explained,
>> these are relatively straightforward to understand. Here is my
>> question: how would I implement the following scenario? My
>> application would use one document type, for example, a BMP image
>> file. And the app requires only one View type appropriate for
>> displaying a BMP file. But it must be able to open many such files
>> and display them all at the same time, each in its own window.
>> This, it seems to me, is fundamentally different from the sample
>> apps I've seen because the document's data changes over the course
>> of the App's run (each time I load a new file) and the view of each
>> (old) set of data must remain constant while that data changes and
>> a new view of that new data is displayed. In fact, I think this
>> scenario is conceptually contrary to MDI as its implemented in the
>> MFC.
>>
>> Am I missing something? or is this just very hard to implement in
>> MFC?
>>
>> Thanks in advance for any and all sagely advice and kind
>> consideration.
>>
>> Roger
>>
>
>
> Your not far off-base here. If your application only handles BMP
> files then you would only need one of each doc/view/frame classes to
> handle them. Now these classes can be reused for each instance of a
> BMP file you happen open. Meaning MFC creates/maintains the objects
> in memory so you can open as many of the objects as your system's
> memory will allow, theoretically :). What you describe in your
> scenario perfectly suits the MDI framework.
>
> --
> ============
> Frank Hickman
> Microsoft MVP
> NobleSoft, Inc.
> ============
> Replace the _nosp@m_ with @ to reply.
>
>



Relevant Pages

  • Re: What could cause ::MessageBox to fail?
    ... >> Do not delete the main window for your app like this. ... > Is it legal to _change_ the main window in an MFC app? ... an SDI app with multiple CFormView views. ...
    (microsoft.public.vc.mfc)
  • Re: Cancel car insurance, pay 80% premium?
    ... window' behalf? ... considering it's perfectly feasible to prevent multiple copies of the same app from running. ... it's this kind of sloppy coding which makes people think windows is ...
    (uk.rec.cars.misc)
  • Re: Remote x11 apps get multiple resize events
    ... When I resize the window, multiple resize events ... Because the app is remote, this can be a slow process - you drag the ...
    (comp.sys.mac.system)
  • Re: Prevent multiple instances of Excel from starting
    ... I didn't have any confusion as regards multiple Excel instances vs multiple ... Does your app call Excel to reference a particular file (which may or may ... I don't have some malicious intent on making life difficult by randomly ...
    (microsoft.public.excel.programming)
  • Re: I need help with mfc doc/view
    ... WHile SDI can support multiple view types, I always worry about SDI apps. ... This is a horrendous step backward from having a single app in which I ... embedded in a remote controller, and when a view calls a document method such as ...
    (microsoft.public.vc.mfc)