Discussion:
using CDocument derived class as an object, How to attach view and frame to an existing object only when it is needed
(too old to reply)
Ebi
2011-11-11 12:41:31 UTC
Permalink
Hello,

When I use (CMultiDocTemplate*)->OpenDocumentFile(NULL), it creates an empty document and attaches a CView derived class to it. but I want to create a document without attaching a view to it and load it with data and only open view when user wants to see the object(document) content. Is there a relatively easy way to do this ?

thank you.
Ebi
ralph
2011-11-12 06:14:14 UTC
Permalink
On Fri, 11 Nov 2011 04:41:31 -0800 (PST), Ebi
Post by Ebi
Hello,
When I use (CMultiDocTemplate*)->OpenDocumentFile(NULL),
it creates an empty document and attaches a CView derived class to it.
but I want to create a document without attaching a view to it and
load it with data and only open view when user wants to see the
object(document) content. Is there a relatively easy way to do this ?
thank you.
Ebi
Well, yes. BUT "easy" sort of depends. <bg>

As you have discovered a Document/View architecture is the default
using the Project Wizard. To avoid this you can create the either of
them from scratch, or you can turn off the option in the Wizard -
recommended as using the Wizard will tend to be "easier" since it will
still add useful code for your document to insure it plays well with
others in the MFC architecture.

Take a look at these articles:
"Alternatives to the Document/View Architecture"
http://msdn.microsoft.com/en-US/library/643sbftd(v=VS.80).aspx
and
"Using Documents"
http://msdn.microsoft.com/en-US/library/cw512c7f(v=VS.80).aspx

Also note that MS no longer supports or uses this newsgroup. All help
and most users now use one of the community forums. For example,
http://social.msdn.microsoft.com/Forums/en-US/vcmfcatl/threads

hth
-ralph
Ebi
2011-11-12 13:00:52 UTC
Permalink
Post by ralph
Also note that MS no longer supports or uses this newsgroup. All help
and most users now use one of the community forums. For example,
http://social.msdn.microsoft.com/Forums/en-US/vcmfcatl/threads
Oh, I would prefer to use usenet group because it has much easier interface and I could add it to my news reader among other groups.
I remember that I read (?) or see (maybe channel 9 ?) comment of a senior manager in VC++ team that had said "till now microsoft used to envision what is best for programmer community and would develop tools in that direction but now we come to this conclusion that it was wrong and we decided to develop tools in the direction that developers community want to moves"
I doubt microsoft will ever do that ;)
I will re-post this to http://social.msdn.microsoft.com/Forums/en-US/vcmfcatl/threads and mention that it had been first posted here.
Post by ralph
Well, yes. BUT "easy" sort of depends. <bg>
As you have discovered a Document/View architecture is the default
using the Project Wizard. To avoid this you can create the either of
them from scratch, or you can turn off the option in the Wizard -
recommended as using the Wizard will tend to be "easier" since it will
still add useful code for your document to insure it plays well with
others in the MFC architecture.
"Alternatives to the Document/View Architecture"
http://msdn.microsoft.com/en-US/library/643sbftd(v=VS.80).aspx
and
"Using Documents"
http://msdn.microsoft.com/en-US/library/cw512c7f(v=VS.80).aspx
well some alternatives that had been suggested there were not to use a CDocument at all and another suggested to put data in CChildFrame. Well my application is not connected to a database so maybe using RecordSet is not appropriate for my application. the ideal solution for my problem is to open a CChileFrame derived object and a CFormView derived object upon request of user to see content of objects. though I have no problem to use a CDocument if I could control when it opens a frame and view(not to open it by default when a document opens).

thank you ralf your post was helpful
ralph
2011-11-12 16:37:45 UTC
Permalink
Post by Ebi
Post by ralph
Also note that MS no longer supports or uses this newsgroup. All help
and most users now use one of the community forums. For example,
http://social.msdn.microsoft.com/Forums/en-US/vcmfcatl/threads
Oh, I would prefer to use usenet group because it has much easier
interface and I could add it to my news reader among other groups.
I share your sentiment.

I understand the reasons why corporations and organizations have moved
away from usernet. Other than the fact Usenet is going out of business
itself, most of them come under the heading of ownership and control.

But what I've failed to understand (although appreciating the
technical issues involved) why the simple intuitive hierarchical
format of Usenet (newsreaders) has not been mimicked.

The real value of a newsgroup was not that one received an answer or
information to a specific query, but that any response was subject to
review and spawned additional responses, corrections, new questions,
and new answers. It is subsquent posts that real value and enlightment
was often found.

With today's "ransom note" format - navigation has become a nightmare.
<g>
Post by Ebi
I remember that I read (?) or see (maybe channel 9 ?) comment
of a senior manager in VC++ team that had said "till now
microsoft used to envision what is best for programmer community
and would develop tools in that direction but now we come to this
conclusion that it was wrong and we decided to develop tools in
the direction that developers community want to moves"
I doubt microsoft will ever do that ;)
I doubt either premise was ever true or ever will be true. <g>

-ralph

Loading...