C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 05-03-2008, 02:56 PM   #1
essence of digital
 
xddxogm3's Avatar
 
Join Date: Sep 2003
Posts: 577
OnPaint and dissappearing graphics

I have created a program that has multiple panels, and created an array of graphic objects for these panels. I have background images on my panels that are drawn over during mouse click. In about 15 seconds after they are drawn over, the graphics disappear and the background image reappears. I implimented an onpain overide function, but it doesn't seem to stop this behavior. Does anyone know what i'm doing wrong?

Code:
        public static void RePaintPlayer(Graphics[] g)
        {
            for (int x = 1; x <= 4; x++)
            {
                if (GS.Players[x].CurrentPosition != 0)
                {
                    g[GS.Players[x].CurrentPosition].FillRectangle(new SolidBrush(Color.Blue), 0, 0, 50, 50);
                    g[GS.Players[x].CurrentPosition].DrawString("Player\n" + x, ArielFont, WhiteColor, new PointF(5, 10));
                }
            }
        }


        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            for (int index = 1; index <= 64; index++)
            {
                GameUI.CorrectImage(index);
            }

            GameUI.RePaintPlayer(GameUI.g);
        }
__________________
"Hence to fight and conquer in all your battles is not supreme excellence;
supreme excellence consists in breaking the enemy's resistance without fighting."
Art of War Sun Tzu
xddxogm3 is offline   Reply With Quote
Old 05-05-2008, 12:41 AM   #2
the hat of redundancy hat
 
nvoigt's Avatar
 
Join Date: Aug 2001
Location: Hannover, Germany
Posts: 2,769
If you have not done so already, consider setting the control styles to something more suited to painting yourself:

http://msdn.microsoft.com/en-us/libr...le(VS.71).aspx

If you do this, you may have to draw the background yourself.

Also, I'd recommend to use a single control for painting. Do the calculations yourself and paint all of it in one control.
__________________
hth
-nv

She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

When in doubt, read the FAQ.
Then ask a smart question.
nvoigt is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump


All times are GMT -6. The time now is 05:09 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22