how to print from vb application

i have made an graphics application.  i draw at the run time according to my need using graphics methods and activex controls.  this is done in the picture box of the form. what i want is that i should be able to print what i have drawn. the printing should be such that it is with perfect scaling as it appears on the screen.
IN SHORT WHAT I WANT IS
PRINTING TECHNIQUE AND CODING
FOR PRINTING BY AN APPLICATION MADE IN VISUAL BASIC.
WITH PRINTPREVIEW IF POSSIBLE.
modijsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
LewyConnect With a Mentor Commented:
I use this code to print a chart that I generated at run time. It does not require it to be saved as a bitmap. you can use the picturebox image instead of the form image. The image is a bitmap but it transfers to the printer well. Try it and see what happens.

This is as close, using VB, to the general PRINTING TECHNIQUES AND CODE used by other programs.
0
 
LewyCommented:
Try something like this:

    Dim PrinterOrientationSave As Integer, L$
    PrinterOrientationSave = Printer.Orientation
    Printer.Orientation = vbPRORLandscape
    Printer.FontName = "Arial"
    Printer.FontSize = 14
    Printer.PaintPicture Form2.Image, _
                        (Printer.Width \ 2) - (Form2.Width \ 2), _
                        (Printer.Height \ 2) - (Form2.Height \ 2)
    Printer.CurrentY = Printer.TextHeight("X") * 2
    Printer.CurrentX = Printer.Width \ 2 - Printer.TextWidth(CurveDataName.Text) \ 2
    Printer.Print CurveDataName.Text
    L$ = Format(Date, "mm/dd/yyyy")
    Printer.CurrentY = Printer.ScaleHeight - Printer.TextHeight(L$)
    Printer.CurrentX = Printer.ScaleWidth - Printer.TextWidth(L$)
    Printer.Print L$
    Printer.EndDoc
0
 
modijsAuthor Commented:
u have used printer object but u have mentioned form.image for printing, this can be done but i need the drawings made at run time in picture box to be printed.  using paintpicture for printer object requires the file to be of bmp format but i want to print the drawing generated in picture box without saving it as bitmap.

i want the general PRINTING TECHNIQUES AND CODE as used in any package like autocad, word etc.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
modijsAuthor Commented:
ur method worked for graphics method like line circle etc in picture box but it did not worked for controls in picture box for eg my own usercontrol, it does not come in the print out, how to do this too
0
 
LewyCommented:
I haven't tryed it but you might be able to BitBlt the image of the control to the printer image in the appropreate location.
Let me know if it works.
0
 
modijsAuthor Commented:
i dont know how to use bitblt so help in this matter in detail.
0
All Courses

From novice to tech pro — start learning today.