Solved

How to get access to the CDC* and CPrintInfo* that are incoming parameters of OnPrint?

Posted on 1997-05-22
5
712 Views
Last Modified: 2013-11-20
What I want to know is, how do you get the current CDC* and CPrintInfo* from a CView class that I created without being in a procedure that has them as incoming parameters.

I'm trying to call OnPrint() from within a procedure that doesn't have the CDC* or CPrintInfo* as incoming parameters.  The reason I want to do this is that I want have a dialog button (not the print dialog) execute the printing functions of a view that I have created.  I have everything set up for this, except I can't get a hold of the CDC* and the CPrintInfo* , and when I try to just declare my own locally, the program crashes on execution.

Thanks for your help in advance,
    Dave
0
Comment
Question by:David Gray
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
RONSLOW earned 25 total points
ID: 1301713
Don't call OnPrint directly (not a good idea generally) - send your view a command message (ID_FILE_PRINT) to do the printing.

Alternatively, you could directly call OnFilePrint (instead of OnPrint).

But - it is better to do a SendMessage because then you don't bypass the message routing logic.


0
 

Author Comment

by:David Gray
ID: 1301714
The problem still remains, in that I need to execute the views printing from an external call in a dialog.  How can I directly send my view a ID_FILE_PRINT from the dialog?  Could you elaborate on the SendMessage?

Thanks,
  Dave
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1301715
Lookup SendMessage in the documentation.

You simply call pMyView->SendMessage(WM_COMMAND,ID_FILE_PRINT);

This sends the ID_FILE_PRINT command to your view class.  This will call the OnFilePrint of the CView or whatever base class which will set up everything and call your view's OnPrint etc, and if you are hooked up to a document template.

If not, try calling OnFilePrint of your view class instead


All should just work fine IF you are deriving from CView (or a derivative of that).

0
 

Author Comment

by:David Gray
ID: 1301716
Much appreciated.

Dave
0
 

Author Comment

by:David Gray
ID: 1301717
I've got it to work in as far as bringing up the print dialog, but when it goes to print nothing is actually written on the page.  Could this be due to the fact that I don't actually have that view running anywhere, I just using it as a means to print the image that I'm drawing on the surface of my own dialog by paralleling the drawing code in the view off of the drawing code in the dialog.  I tried a simple pDC->TextOut(0,0,"Hello World!") and that didn't even write to the page.  I'm stumped.  Any ideas?

Dave
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question