Document/View design decisions

Started by
2 comments, last by tebriel 20 years, 3 months ago
I''m trying to get the hang of MFC Doc/View architecture, so far the toughest part is figuring out where things should go. I have an SDI application that requires me to prompt the user with a dialog every time a new "document" is created (i.e. new is chosen from the File menu). I''m not sure if I should put this dialog in the View''s constructor, OnInitialUpdate(), or somewhere else. Where would something like this go, or am I using the wrong approach?
Advertisement
Stupid question, too specific, or too hard?
Why not just put it in the menu handler for File->New ?
Have a virtual function on your "document" object that shows the prompt it needs. Then, when "new" is selected, create the object, run the function, which shows the prompt, and depending on the outcome, save or delete the newly created object, or set its properties.

If the prompt allows you to select the type of document, make it part of the document code, but as a static function or (maybe) a global function in the same module. That way, you''ll have directly access to other data concerning documents. Simply call the function when "new" is selected and let the prompt take care of the rest.

This topic is closed to new replies.

Advertisement