Click here to Skip to main content
15,917,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,I have question about printdialog box.I have written program in c++.in that i want to display printdialog box and give one file inpute for printing.i know how to display printdialog box but did't find way pass inpute file name which i want print through printer.i have used cprintdialog class.
could u please help me!!!!
Posted
Comments
Nelek 24-Mar-12 6:26am    
Can you use "improve question" and add some relevant code? Just for your description is quite difficult to find out what you want / where the error is.

1 solution

The CPrintDialog is meant to print whatever is the current document. Therefore it doesn't take a file name as input. I would recommend you do the following:

- Open the file with a CFileDialog

- Load and possibly display the contents of the file, so the user can verify what he is about to print

- Let the user click the Print command, either in the File dialog or by some other UI-element

- Then use the CPrintDialog to let the user choose which pages of the current document to print.

Another method would be to subclass the CPrintDialog and add a file path edit box in there, but that does need a lot more expertise than the way shown above. And it would be somehow counter-intuitive for most users.
 
Share this answer
 
Comments
RICKY_Xxx 25-Mar-12 11:00am    
thanks for reply.can u give me code.
RICKY_Xxx 25-Mar-12 11:05am    
it is just an if else condition if condition false there is file at one of the location.i should give file to printing.
nv3 25-Mar-12 14:18pm    
I don't get what you are saying. What is just in an if-else condition?

To print an arbitrary file is not as simple as it looks. Are you talking about a Word file, a PowerPoint file, or a PDF file etc.? To print any of those you need a piece of code that understands the format those files are written in. So you normally want to send these file to the application that created them and have the application interpret the contents of the file and send it to the printer. Is that what you are aiming at?
RICKY_Xxx 26-Mar-12 0:14am    
file format is pdf
nv3 26-Mar-12 11:47am    
So use a CFileDialog to find out, which file the user wants to print. Then generate a command line string with

AcroRd32.exe /N /T PdfFilePath PrinterName [ PrinterDriver [ PrinterPort ] ]

and let the execute by the shell. Is that what you want to do?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900