How to print graphics in picturebox control

How to print graphics in picturebox control

Post by John Won » Fri, 10 Apr 1998 04:00:00



Steps to generate a simple application:

        1.Start a new project in Visual Basic. Form1 is created by
default.
        2.Place a Picture box on Form1. Picture1 is created by defaut.
        3.Place a Command control on Form1.
        4.Insert the following codes:
                Private Sub Form_Load()
                        Picture1.Line (0, 0)-(5000, 5000), vbRed
                End Sub

What is effective way to print out the graphic line in picturebox?

Thanks for help.

John Wong

 
 
 

How to print graphics in picturebox control

Post by Jim Deutc » Fri, 10 Apr 1998 04:00:00


The most effective way to print out graphics that you've drawn into a
picturebox is to re-draw them on the printer object.  This produces a
scalable, hi-resolution printout.

Alternatively, you can use PaintPicture from the picturebox to the printer
object, but that won't give you any better resolution than you have on the
screen.

Jim Deutch
MS Dev MVP


> Steps to generate a simple application:

>            1.Start a new project in Visual Basic. Form1 is created by
> default.
>            2.Place a Picture box on Form1. Picture1 is created by defaut.
>    3.Place a Command control on Form1.
>    4.Insert the following codes:
>            Private Sub Form_Load()
>                            Picture1.Line (0, 0)-(5000, 5000), vbRed
>            End Sub

> What is effective way to print out the graphic line in picturebox?

> Thanks for help.

> John Wong



 
 
 

How to print graphics in picturebox control

Post by John Won » Fri, 10 Apr 1998 04:00:00


Some more questions:

1. How to save the graphics in the picturebox to a file?

2. I used the following code:
        Private Sub Command1_Click()
                Printer.PaintPicture Picture1.Picture, 0, 0
        End Sub

and got "runtime error '481', invalid picture", because "An invalid
graphics format was assigned to the Picture property. This error has the
following cause and solution: You tried to assign a graphics format
other than a bitmap, icon, or Windows metafile to the Picture property
of a form or control.Ensure that the file you are trying to load into
the Picture property is a valid graphics file supported by Visual
Basic."

John Wong


> The most effective way to print out graphics that you've drawn into a
> picturebox is to re-draw them on the printer object.  This produces a
> scalable, hi-resolution printout.

> Alternatively, you can use PaintPicture from the picturebox to the printer
> object, but that won't give you any better resolution than you have on the
> screen.

> Jim Deutch
> MS Dev MVP


> > Steps to generate a simple application:

> >               1.Start a new project in Visual Basic. Form1 is created by
> > default.
> >               2.Place a Picture box on Form1. Picture1 is created by defaut.
> >       3.Place a Command control on Form1.
> >       4.Insert the following codes:
> >               Private Sub Form_Load()
> >                       Picture1.Line (0, 0)-(5000, 5000), vbRed
> >               End Sub

> > What is effective way to print out the graphic line in picturebox?

> > Thanks for help.

> > John Wong


 
 
 

How to print graphics in picturebox control

Post by Jim Deutc » Tue, 14 Apr 1998 04:00:00


Add

Printer.Print ""

before the paintpicture, and

Printer.EndDoc

after, and all should be well.

Jim Deutch
MS Dev MVP


> Some more questions:

> 1. How to save the graphics in the picturebox to a file?

> 2. I used the following code:
>    Private Sub Command1_Click()
>                    Printer.PaintPicture Picture1.Picture, 0, 0
>    End Sub

> and got "runtime error '481', invalid picture", because "An invalid
> graphics format was assigned to the Picture property. This error has the
> following cause and solution: You tried to assign a graphics format
> other than a bitmap, icon, or Windows metafile to the Picture property
> of a form or control.Ensure that the file you are trying to load into
> the Picture property is a valid graphics file supported by Visual
> Basic."

> John Wong


> > The most effective way to print out graphics that you've drawn into a
> > picturebox is to re-draw them on the printer object.  This produces a
> > scalable, hi-resolution printout.

> > Alternatively, you can use PaintPicture from the picturebox to the
printer
> > object, but that won't give you any better resolution than you have on
the
> > screen.

> > Jim Deutch
> > MS Dev MVP




- Show quoted text -

> > > Steps to generate a simple application:

> > >               1.Start a new project in Visual Basic. Form1 is created
by
> > > default.
> > >               2.Place a Picture box on Form1. Picture1 is created by
defaut.
> > >       3.Place a Command control on Form1.
> > >       4.Insert the following codes:
> > >               Private Sub Form_Load()
> > >                       Picture1.Line (0, 0)-(5000, 5000), vbRed
> > >               End Sub

> > > What is effective way to print out the graphic line in picturebox?

> > > Thanks for help.

> > > John Wong


 
 
 

1. Print/save entire PictureBox w/ child controls

Hi,

Though I've asked this question before, I have some new
twists on this problem.

My project (which is similar to MS Paint, but with VB
controls on the drawing that can be manipulated) needs to
be able to print out the entire contents of a picturebox,
part of which may not be visible on-screen, as well as
save it as a bitmap.

Up until now, using WM_PAINT and WM_PRINT messages with
appropriate flags (ie. PRF_CHILDREN, etc.) has worked
fine.  But since then, I've added UserControls that appear
on the drawing surface that contain lightweight controls;
when using this method, the control is not painted and is
completely transparent.  Likewise, UserControls that use
picture boxes won't paint the bitmap assigned to it,
showing only the border of the picture box with the
interior transparent.

I've tried manually adding shapes and images to produce
the final image, but that won't take the Z-order into
account.

If you have any idea how to go about solving this issue, I
would greatly appreciate it.

Thanks,
MB

2. realistic underwater, please help

3. Printing a picturebox when it contains controls.

4. Deep Canvas patent?

5. Printing Image of all controls in picture box to 2nd picturebox

6. How do I set a Checkbox/OptionButton to transparent?

7. Transparent PictureBox control

8. OT:DDR vs RDRAM

9. How to save WMF to BMP without PictureBox Control

10. vb6 Picturebox used in activex-control with access report

11. PictureBox Control and small icon

12. create file from picturebox control

13. Color Count of image in an image (or picturebox) control