C# OnPaint Event

Associate
Joined
1 Feb 2006
Posts
1,868
Location
Reading
Is there anyway i can prevent this event firing for a specified period?

I'm drawing something onto a form using an api but afterwards the onPaint method fires repainting the form and removing what i wanted to draw :(
 
If OnPaint isn't called, the form isn't painted though, resulting in a blank white areas if the form is invalidated. The only way to fix it is to draw whatever it is you want on it every time the form is painted. You could use double buffering to draw it to an image, then draw that image every time (assuming you have control over the Graphics object used to draw).
 
well it doesnt matter if it doesn't repaint as the form never goes out of sight.

Basically i have a card game, the onPaint event paints all the players cards face down, however i would like a button that whn pressed down shows they cards face up and when they release the button they return to face down.

Problem is when the show button is pressed it paints the relevant cards face up but then causes the onPaint which prints the cards face down again! :mad:
 
Why not just add a boolean variable that defines whether the cards should be drawn face up or face down? Just invert it when the button is pressed and invalidate the form (using Invalidate()) to cause the form to be repainted appropriately.
 
Yea that is what all my ideas have come too, will need an extra var to determine which specific player's cards to show.

Thanks.
 
Got it working that way although it does flicker when it happen it shows the cards due to repainting, bit annoying.
 
Back
Top Bottom