Skip to main content
GameDev.net gamedev.net
🔒 Locked

Windows Paint Event Issue

Started by JimboC Sep 28, 2009 at 7:29 PM 2 replies 1.6k views
Original Post
JimboC
JimboC
The program I'm writing is a Windows app using forms. On the main form there is a panel and I add all sorts of other controls to this panel such as labels, other panels, pictureboxes, etc. Then I connect the groupings using lines drawn on the main panel using the drawing functions. Everything works fine until the window is resized, minimized or the panel is scrolled. Opening other windows, moving other programs over the top of mine, etc don't seem to be an issue. But when my programs window is resized, the lines aren't redrawn from the code I'm calling from the Paint event. I've tried duplicating the paint event code into other events but the results seem to be the same. I can see the lines being drawn and then erased immediately afterwards if it's an even I can call a lot (like scrolling the panel). I've tried invalidating the panel in a number of different places in the code and they don't seem to help. Can someone point me in the direction of what else might be going on? I have a feeling there's some other event firing but I can't seem to figure out what it is.
MJP
MJP
If you're doing custom drawing in your control, then you may want to override OnPaintBackground so that it doesn't clear out what you've already drawn.
JimboC
JimboC
Thanks for getting back to me.

I don't see a PaintBackground event to override, but I tried over riding BackColorChanged, BackgroundImageChanged and BackgroundImageLayoutChanged and I'm still having the same issue.

Was one of those events the one you were referring to?
JimboC
JimboC
Found the issue. I have a flag that suppresses redrawing in certain circumstances and it seems I forgot to set that flag in another part of the program.

That's for the input though.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.