How do I use paint?

Hello,

I got this message…
Graphics is deprecated. You should use paint instead

How do I code this with Paint?
Graphics.DrawPicture p, 821, 5 - (Canvas1Height-144)/2, 144, Canvas1Height, 0, 0, p.Width, p.Height

Thanks.

Lennox

take a look here graphics

Thanks Loannis, did that before asking, and I still see Graphics.Drawpicture being used…

Graphics.DrawPicture ( Image as Picture, X as Integer, Y as Integer [,DestWidth as Integer ] [, DestHeight as Integer ] [, SourceX as Integer ] [, SourceY as Integer ] [, SourceWidth as Integer ] [, SourceHeight as Integer] )

The following code crops the image. It copies only the top 150 pixels of the original image at full size:
g.DrawPicture(myImage,0,0,600,150)

The following code crops and scales the image. The top half of the image is retained and the DestWidth and DestHeight parameters specify a 50% reduction.
g.DrawPicture(myImage,0,0,300,228,0,0,600,457)

If you don’t want to scale or crop the image, you can leave off the last six parameters. In this case, it will appear full-size.
g.DrawPicture(myImage,0,0)

Lennox

in paint…

g.DrawPicture p, 821, 5 - (Canvas1Height-144)/2, 144, Canvas1Height, 0, 0, p.Width, p.Height

The confusion may be that the term Graphics is used both for a class and for a property of Canvas (and that property is of type Graphics). What is deprecated is not the class, but to refer to the Canvas.Graphics property directly. Instead, use the Graphics instance, g, that is passed to the Paint event (as Jeff T. wrote in fewer words).

To add even more kerosene…
Graphics is a property of PICTURE, and is still valid to use

What you CANNOT do, and Jeff gave the solution, is refer to the GRAPHICS property of a CANVAS from outside its PAINT event, but the GRAPHICS property of a PICTURE can still be referred to from “anywhere”

Thanks for the clarification.

Lennox