Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 1997-05-22
5
Medium Priority
?
716 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 50 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

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.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

722 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