Link to home
Start Free TrialLog in
Avatar of modijs
modijs

asked on

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.
Avatar of Lewy
Lewy

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
Avatar of modijs

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Lewy
Lewy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of modijs

ASKER

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
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.
Avatar of modijs

ASKER

i dont know how to use bitblt so help in this matter in detail.