Solved

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

Posted on 1997-05-22
5
698 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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…
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now