Solved

OnPrint() not executing correctly...

Posted on 1997-05-27
9
357 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
  • 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
 
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
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.

 
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

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

Title # Comments Views Activity
cat dog challenge 18 124
difference between String.subString() and String.subSequence() 6 180
unix example issues 18 76
Problem to open Excel file 15 99
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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

24 Experts available now in Live!

Get 1:1 Help Now