" active" <ac****@REMOVEa-znet.com> schrieb
I realize that the quick test I had did seemed to work but it was
not correct.
I have a usercontrol containing a picturebox that I want to draw
on. What happens is I'm drawing on the UserControl instead.
Then you can paint in the Picturebox' paint event.
An alternative is to derive your own class from the Picturebox class and
override OnPaint - but currently this does not make the difference.
I guess you declared g1 and b1 at class level? (a field in the
class)
In Sub New I'd probably write
dim g as graphics
g = me.creategraphics
can't use g1 here? Why do we need g?
It was _you_ who created a new Graphics object. In your first posting you
wrote
b1 = New Drawing.Bitmap(Width, Height, Me.CreateGraphics())
I changed this and assigned the return value of Me.CreateGraphics to the
variable to be able to call the Dispose method afterwards.
b1 = New Drawing.Bitmap(Width, Height, g)
I don't understand why dispose and then get a new one.
What is this for?? g.dispose '<- dispose here
g1 = Graphics.FromImage(b1)
See comment above: You also created two Graphics objects. I guess you did it
because you wanted this for the reason described in the documentation for
the constructor when passing a graphics object: The resolution of the
graphics object is applied to the bitmap.
What should I do if the Box is resized??
I'd call g1.dispose, b1.dispose and recreate the bitmap. So, the
Bitmap creating lines should be a separate proc called from the
ctor and in OnResize.
recreate the graphics in the bitmap is not possible. Think of
Photoshop and the user resizes after drawing.
What does this mean? You can copy the old Bitmap into the new Bitmap if you
don't want to loose the content.
--
Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html