Hi,
I'm writing an app that will show a scrolling transparent graph and I'm
ancountering some problems, explained in the following code:
(a VS project explaining the problem(s) can be downloaded at
http://www.icat.be/problems.zip )
The code is executed on a timer.tick event:
// Draw Using Double Buffering, this works perfectly if the monitor
// is set to 16-bit Color mode, if it is set to 32-bit color mode
// the background of the graph will be blue, I know this is a known bug
// bug ID KB820640, will Microsoft resolve this ????
BackgroundBmp.MakeTransparent(Color.Red);
this.OffScreenBmp = new Bitmap(BackgroundBmp);
this.OffScreenDC = Graphics.FromImage(this.OffScreenBmp);
Graphics ClientDC = this.CreateGraphics();
BackGroundBrush = new SolidBrush(Color.Blue); //Blue is the tranparencykey
of the form
this.OffScreenDC.FillRectangle(BackGroundBrush,0,0 ,this.NumberOfLines,MaxVal
);
for(int i=0;i<CounterArray.Count;i++)
{
Pen myPen = new Pen(Color.Red,1);
//Draw all the vertical Lines
this.OffScreenDC.DrawLine(myPen,i,MaxVal,i,MaxVal - (int)CounterArray[i]);
}
//Put it on the screen
ClientDC.DrawImage(this.OffScreenBmp,0,0);
// Draw using the Region property of Panel1, works perfectly on first sighth
// but when you place this app behind another window, and bring it back to
the
// front, the graph looks kinda "garbled", I don't know why, can someone
explain this?
// Is this a bug ???
myPath = new GraphicsPath();
//Add all the vertical lines to the path
for(int i=0;i<CounterArray.Count;i++)
{
myPath.AddLine(i,this.panel1.Height,i,this.panel1. Height -
(int)CounterArray[i]);
}
// Close the Path
myPath.AddLine(CounterArray.Count,this.panel1.Heig ht -
(int)CounterArray[CounterArray.Count -1],CounterArray.Count,this.panel1.Heig
ht);
this.panel1.Region=new Region(myPath);