473,396 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

form.doublbuffered problem


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
Oct 24 '06 #1
2 1452
Hi Steve,

Don't call CreateGraphics. Instead, pass in e.Graphics to your Draw method.

--
Dave Sexton

"Steve" <cc******@bigpond.net.auwrote in message
news:qI*******************@news-server.bigpond.net.au...
>
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

Oct 24 '06 #2
so simple - many thanks

rgds,Steve

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:u8**************@TK2MSFTNGP05.phx.gbl...
Hi Steve,

Don't call CreateGraphics. Instead, pass in e.Graphics to your Draw
method.

--
Dave Sexton

"Steve" <cc******@bigpond.net.auwrote in message
news:qI*******************@news-server.bigpond.net.au...
>>
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.Re d);
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


Oct 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Richard | last post by:
Hi, I have a form that take some time to load due to many comboboxes and at least 8 subforms. When I filter or sort the main form I get an error message and then Access shuts down. They ask if...
15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
5
by: Steve Strik | last post by:
My Problem: I have created a database here at work that is exhibiting some very strange behaviour. Essentially the database is structured in a manner where one table is a master record table...
1
by: Nico | last post by:
Hi! I use Windows XP and Access 2002 (XP) SP2 (not SP3) My company has not upgraded to SP3. My problem: -I have a form "F_BOMs" -in this form, i have a sub form called "SF_BOMs" -the sub-form...
3
by: dixie | last post by:
I have an Access 2000 form which has been running OK for a long time. Lately, it is playing up and doing things like causing Access to close suddenly when the form is opened or when saving the form...
9
by: Lyn | last post by:
Hi, I have a form which is opened from a button on another form. The form is used to display a list of records from a recordset in Continuous Mode. It is sized vertically to display about 25...
5
by: ortaias | last post by:
I have a form which calls up a second form for purposes of data entry. When closing the data entry form and returning to the main form, things don't work as expected. When I return to the main...
11
by: ChrisM | last post by:
Hi, Don't know if anyone can cast any light on this... I have a fairly complex C# WinForm with (amongst other) a text box and a button. The TextBox has events declared for KeyUp and KeyDown,...
1
by: fugaki | last post by:
Hi everyone I'm learning asp, and i downloaded this script to teach me how to post form data from a webpage to an access database. I put it on the server so i could make sure that it worked, and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.