Solved

OnPrint() not executing correctly...

Posted on 1997-05-27
9
362 Views
Last Modified: 2013-11-20
I'm sending a SendMessage(WM_COMMAND, ID_FILE_PRINT) to a view of mine from a dialog that I have written.  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 to that of the drawing code in the dialog. I tried a simple pDC->TextOut(0,0,"Hello World!") in OnPrint() and that didn't even write to the page.  Could it possibly be due to the fact that the print is being called from a modal dialog I wrote? I'm stumped. Any ideas?

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
  • 4
  • 3
  • 2
9 Comments
 

Author Comment

by:David Gray
ID: 1301833
Edited text of question
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1301834
The call from a modal dialog shouldn't make any difference.

Do you not have a view window created?  That could explain why nothing happens because there is no window to receive the messages.

Could you please post some code for me to look at.

I am at Roger_Onslow@compsys.com.au
0
 

Author Comment

by:David Gray
ID: 1301835
I don't actually have the view created.  Would you suggest that I create the window and then hide it to accomplish what I want.  I don't actually want to display the view, just use it for the printing capabilities.

I'll e-mail you the code I'm using soon.

Thanks,
    Dave
0
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!

 
LVL 1

Expert Comment

by:jmmougeolle
ID: 1301836
Are you sure the OnPrint method is called? Try to put a MessageBox call there so to be sure it's really called, or a BreakPoint.

So if you wanna try the Messagebox think just try a:

::AfxMessageBox("I'm in OnPrint",);
Before or after your TextOut...

jmmougeolle@calva.net
0
 
LVL 1

Expert Comment

by:jmmougeolle
ID: 1301837
Are you sure the OnPrint method is called? Try to put a MessageBox call there so to be sure it's really called, or a BreakPoint.

So if you wanna try the Messagebox think just try a:

::AfxMessageBox("I'm in OnPrint",);
Before or after your TextOut...

jmmougeolle@calva.net
0
 

Author Comment

by:David Gray
ID: 1301838
I actually have already tried putting a message box in the OnPrint(), and it never displayed.

Dave
0
 
LVL 1

Accepted Solution

by:
jmmougeolle earned 50 total points
ID: 1301839
So that's mean it never called! What you got to do to check what's going wrong is to put a break point in the CView::OnFilePrint, and even, if it's not handling the reception of your message, just try to call it directly.... That's will normally work...

If that's not working either, it don't seems that the code that is included in the OnFilePrint MFC source code is not easy enough to not be directly managed by your own code, and do what ever you want it to do, to be able to print form your dialog. SO you o could try to make it a new method of your CDialog, and make it work from there....
May the MFC be with you....
 jmmougeolle@calva.net strikes back!
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1301840
Ths problem is as I said before - if there is no window, then there is nothing to receive the message.

Think I deserve points for that!!

0
 

Author Comment

by:David Gray
ID: 1301841
I actually do think that Ronslow's appraoch is more likely to be what my problem is.  I think Ronslow deserves the points as well, but I'm not sure how to grade this because it says that the points will go to jmmougeolle's answer.

Anyway, for Ronslow, how would I go about creating the view without making it visible and have so that it is there to receive the message.  Right now I have code associated with a button on my dialog that looks somewhat like:

CMyView* pView;
pView->SendMessage(WM_COMMAND,ID_FILE_PRINT);

How can I "create the window", as you say?

Thanks,
   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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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 an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

740 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