printing problem with commondialog

I am able to show out the print dialog box with the
commondialog1.showprinter command
but I am not able to execute the printing when Ok button is pressed.Please advice me on what I have lack??
yylAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
kianweiConnect With a Mentor Commented:
Common Dialog only used for select/change printer properties. i.e. It's
will change the printer property after u press 'OK'.

U need extra statement to print the trigger the printing, for example, if u r using
the Crystal Report, u need to set the Action property to 1 (Crytal.Action = 1)
to start print the report.
0
 
mark2150Commented:
You have to add a series of Printer.Print statements to get anything to actually *go* to the printer. You can also draw lines and circles and such with Printer.Line, Printer.Circle. Basically you treat it as any other control. .CurrentX and .CurrentY allow you control of the cursor, .FontSize and related commands control the fonts, etc. You have to finish up with a Printer.EndDoc in order to submit the job into the print queue.

Windows stands between your app and the printer. You send out a bunch of printer commands and they *do not* go directly to the printer! They go to a "meta" device. Advantage to this is that you can move up the page as well as down, etc. Then when your code sends a .EndDoc this alerts Windows that you're done using the app.

Windows then looks at the printer device specifics and converts your "meta" page into a series of commands specific for the printer you selected with the CommonDialog control. *THEN* data is sent to the printer - not before. The other advantage to this is that your code will render at the "best possible" resolution/quality depending on the specifics of the printer and *NOT* on the basis of your code. This allows your program to automatically upgrade it's print quality when a "better" printer is selected.

M

0
 
yylAuthor Commented:
I am actually trying to print the text in picture1 using vb5.Can you please show example of the code.
Much appreciate also if you could let me know where to look for the helps topic on " commondialog box_print" as  I am unable to find it in MS Visual Basic Helps.
Thanks for your kind attention.

0
 
mark2150Commented:
Picture1.Print "This is a line of text"

Look in the help on "CommonDialog Control (Print Dialog)"

But this does *NOT* actually print anything. It just allows you to connect to the printer. Your code still needs to send print commands.

If you want to print an image you need to code:

Printer.PaintPicture Picture1.Picture, x, y

This will print the contents of a picture box including any text that was placed in it. However you might find you get better results by printing the image without text and then printing the text on the printer. This will generally give you higher quality text than printing the text in the picture box.

M

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.