How to store a PaintEventArgs Object

JDT_71

Member
Joined
Jul 11, 2006
Messages
7
Programming Experience
Beginner
Is there a way to "grab" a PaintEventArgs object, make a copy, and set a PaintEventArgs object variable equal to it so that I can use that PaintEventArgs object whenever I want and not be forced to do so in the context of the OnPaint routine?
 
This doesn't sound like a good idea at all.
Tell us what you're trying to accomplish and we'll be able to help you find a better solution.
You should almost always be using the Paint event handler to do your custom drawings.
 
I agree with Paszt, but if you want to create a graphics object that behaves it'sself better than using 'CreateGraphics' then you can use the following.....


VB.NET:
Dim G as Graphics = Graphics.FromHdc(Handle to the object you want to draw on)
or

VB.NET:
Dim G as Graphics = Graphics.FromHdcInternal(Same argument as above)

This is a graphics object directly to a device context. Remeber to dispose of it when finished


EDIT: You may well need to to a GetWindowDC API for that to work. If you get an 'OutOfMemoryError' then let me know.
 
Last edited:
Back
Top