Solved

OnPrint() not executing correctly...

Posted on 1997-05-27
9
363 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
Technology Partners: 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Host to IP 7 84
Looking for a specific application/software 2 124
Detect CR LF to each line 12 185
Hibernate methods 2 87
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Suggested Courses

734 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