Dick Donny Posted January 6, 2005 Posted January 6, 2005 This is probably a really simple thing to fix (must be a very common issue) but I'm struggling to figure out what to do ... hope you can help. On a Paint event I am creating a bitmap that scales to the full drawing rect. It all works ok until the rect is increased in size (and then is ok sometimes and not others) It appears the device context is doing something behind the scenes to determine that it actually does not need to draw a specific part of the returned bitmap, however, the paint event is fired via an Invalidate call as opposed to a window being dragged over it, so not sure how it has determined what to draw and what not to draw. Anyway, the result it that when the rect space increases, part of the rect is not redrawn, and a bit of the old bitmap is still visible. I've enclosed a screen shot to show what I mean. I've been looking at the translatetransform procedure, but I'm not sure if this is the right approach. Any help would be appreciated. This is my code if it's of any use. e.Graphics.Clear(m_canvas.BackColor) Dim rect As New Rectangle(New Point(0, 0), m_canvas.Size) Dim db As New RA.Utilities.Drawing.Drawing2D.GraphicsDoubleBuffer(rect) db.Store() m_renderer.Paint(db.Store, rect) e.Graphics.DrawImage(db.Canvas, rect) db.Dispose() Shown above is the code I use in the actual paint event of the picture box (m_canvas). m_renderer is an interface into an object that exposes a Paint method. This method always draws a bitmap for the passed rect, which is the full size of the picture box. db is just a double buffering class I use. Thanks in advance of any help you can offer.untitled.bmp Quote
Dill Posted March 2, 2005 Posted March 2, 2005 Same again i think. For some reason the paint even is not called when a control is resized. I think standard controls must call the paint event explicitly. I had this problem with my GDI buttons. It was ok if i enlarged the control but went nuts if i tried to reduce the size. And sometimes there were residue bits of the old image. I solved it by a simple me.refresh in the controls resize event. Dill Quote
Dick Donny Posted April 4, 2005 Author Posted April 4, 2005 Same again i think. For some reason the paint even is not called when a control is resized. I think standard controls must call the paint event explicitly. I had this problem with my GDI buttons. It was ok if i enlarged the control but went nuts if i tried to reduce the size. And sometimes there were residue bits of the old image. I solved it by a simple me.refresh in the controls resize event. Dill Thanks for that, but it's not the same issue. Your problem is because when a control is reduced in size, the control does not believe it needs to repaint (it already has the reduced region paint). You need to post a me.invalidate(rect) message and it'll work fine. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.