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
Solved

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

790 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