S
Steve
I use the paint event to call an external object that will write text
and or drawings to the form - (to make it persistant)
If i have the form property DoubleBuffered set to true the text will
only occassionaly display on the form.
However when I set the doublebuffered property false everything is fine
(except that i get flicker).
If I put the code from the class into the actual paint event it works
fine in both cases,
I presume that the hidden 'other' buffer is not updated if the code is
outside the paint event.
Has anyone struck this problem or have a solution to this - ?
Note that i am calling a number of objects with virtual overridden Draw
methods from within the
forms paint method so placing the code in the forms paint event is not an
option
a sample of my code:
private void frmChart_Paint(object sender, PaintEventArgs e)
{
foreach (Indicator ind in Indicators) // a generic list<MyObjects>
{
ind.Draw();
}
}
The Indicator class + one inherited class
public class Indicator
{
public SolidBrush myBrush = new
System.Drawing.SolidBrush(System.Drawing.Color.Red);
public Graphics formGraphics;
public static int drawcount;
public frmChart IndicatorOwner;
public Rectangle rect = new Rectangle();
public string size = "Large";
public Indicator(frmChart C)
{
IndicatorOwner = C;
}
public virtual void Draw()
{
formGraphics = IndicatorOwner.CreateGraphics();
}
}
public class PriceIndicator : Indicator
{
public PriceIndicator(frmChart C) : base(C)
{
}
public override void Draw()
{
base.Draw();
Pen myPen = new Pen(System.Drawing.Color.Red);
formGraphics.DrawRectangle(myPen, rect); // THIS AND
String drawString = "Sample Text"; // THIS ONLY DISPLAYS SPASMODICALLY ON
THE FORM WHEN DOUBLEBUFFERED PROPERTY IS SET
}
rgds,Steve
and or drawings to the form - (to make it persistant)
If i have the form property DoubleBuffered set to true the text will
only occassionaly display on the form.
However when I set the doublebuffered property false everything is fine
(except that i get flicker).
If I put the code from the class into the actual paint event it works
fine in both cases,
I presume that the hidden 'other' buffer is not updated if the code is
outside the paint event.
Has anyone struck this problem or have a solution to this - ?
Note that i am calling a number of objects with virtual overridden Draw
methods from within the
forms paint method so placing the code in the forms paint event is not an
option
a sample of my code:
private void frmChart_Paint(object sender, PaintEventArgs e)
{
foreach (Indicator ind in Indicators) // a generic list<MyObjects>
{
ind.Draw();
}
}
The Indicator class + one inherited class
public class Indicator
{
public SolidBrush myBrush = new
System.Drawing.SolidBrush(System.Drawing.Color.Red);
public Graphics formGraphics;
public static int drawcount;
public frmChart IndicatorOwner;
public Rectangle rect = new Rectangle();
public string size = "Large";
public Indicator(frmChart C)
{
IndicatorOwner = C;
}
public virtual void Draw()
{
formGraphics = IndicatorOwner.CreateGraphics();
}
}
public class PriceIndicator : Indicator
{
public PriceIndicator(frmChart C) : base(C)
{
}
public override void Draw()
{
base.Draw();
Pen myPen = new Pen(System.Drawing.Color.Red);
formGraphics.DrawRectangle(myPen, rect); // THIS AND
String drawString = "Sample Text"; // THIS ONLY DISPLAYS SPASMODICALLY ON
THE FORM WHEN DOUBLEBUFFERED PROPERTY IS SET
}
rgds,Steve