Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 333
  • Last Modified:

CView without a document

When creating a SDI application without document/view support, the frame's view is derived from CWnd. Is it ok to derive this view from CView and not attach a document? Will I need to set the document pointer to NULL?
0
tds195
Asked:
tds195
1 Solution
 
fstabCommented:
Yes it is perfectly allowable for you to derive it from CView and not attach a document. What do you mean by "Will I need to set the document pointer to NULL" - where do you want to set it to NULL ?
0
 
plarocheCommented:
What in the CView(without a document) would you need that is not in a CWnd?
0
 
tds195Author Commented:
I was thinking about the fact that you normally use a CSingleDocTemplate to associate the document with the view and was wondering how where this association is made.2
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
tds195Author Commented:
I need to support printing and drag and drop.
0
 
heyhey_Commented:
what's the problem with having a document ?

0
 
plarocheCommented:
Also, what is a SDI without document/view support?  The D in SDI means Document.....

Yes you can replace it by a CView if your CView has a NULL document.  If you check MFC code most view class members check for a NULL document (see viewcore.cpp) and handle it correctly.  

Your printing mecanism will also work, the doctitle will come from the frame window's title (see viewprnt.cpp).

If your existing CWnd object that you wish to replace is already plugged in the command-message routing then you won't have any problems. If it is not plugged in your view won't get the ID_FILE_PRINT command to print its stuff.  Your frame might trap the message and relay it to the view or override OnCmdMsg in your frame and call the view's OnCmdMsg first. This will effectively plug the view in the command message routing.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now