Solved

printing problem with commondialog

Posted on 1999-01-24
4
155 Views
Last Modified: 2010-05-03
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??
0
Comment
Question by:yyl
  • 2
4 Comments
 

Accepted Solution

by:
kianwei earned 100 total points
ID: 1470360
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
 
LVL 12

Expert Comment

by:mark2150
ID: 1470361
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
 

Author Comment

by:yyl
ID: 1470362
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
 
LVL 12

Expert Comment

by:mark2150
ID: 1470363
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

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

929 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

14 Experts available now in Live!

Get 1:1 Help Now