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

OnPrint() not executing correctly...

Posted on 1997-05-27
9
361 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand data scrubbing tool 13 35
method notes when mouse over in eclipse 5 87
format the code in java 6 101
withoutTen challenge 14 131
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 …
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

839 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