Scrollpager doevents and margins of the main chart
Scrollpager doevents and margins of the main chart
Please find attached this example
http://193.145.251.126/pnp/files/uOpbmT ... Scroll.zip
If you press button10 and then button1, the margin of the main chart is not correct. But if you comment the "DoEvents" instruction it runs sucessfully. Why?
Thanks
http://193.145.251.126/pnp/files/uOpbmT ... Scroll.zip
If you press button10 and then button1, the margin of the main chart is not correct. But if you comment the "DoEvents" instruction it runs sucessfully. Why?
Thanks
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Scrollpager doevents and margins of the main chart
I'm not sure, but according to this MSDN article:wakeup wrote:If you press button10 and then button1, the margin of the main chart is not correct. But if you comment the "DoEvents" instruction it runs sucessfully. Why?
Caution
Calling this method causes the current thread to be suspended while all waiting window messages are processed. If a message causes an event to be triggered, then other areas of your application code may execute. This can cause your application to exhibit unexpected behaviors that are difficult to debug. If you perform operations or computations that take a long time, it is often preferable to perform those operations on a new thread. For more information about asynchronous programming, see Asynchronous Programming Model (APM).
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Scrollpager doevents and margins of the main chart
Christopher wrote:I'm not sure, but according to this MSDN article:wakeup wrote:If you press button10 and then button1, the margin of the main chart is not correct. But if you comment the "DoEvents" instruction it runs sucessfully. Why?
Caution
Calling this method causes the current thread to be suspended while all waiting window messages are processed. If a message causes an event to be triggered, then other areas of your application code may execute. This can cause your application to exhibit unexpected behaviors that are difficult to debug. If you perform operations or computations that take a long time, it is often preferable to perform those operations on a new thread. For more information about asynchronous programming, see Asynchronous Programming Model (APM).
As you can see in the example application it doesn't do anything special with doevents.
It is only a example application to reproduce the problem I have in the real application, it is because the user adds the series, and after do other things it fills it with data. This is only a demonstration it is a error in the teechart.
In fact, you can export this chart with the problem in the margin, and if you open it again the problem is solved...
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Scrollpager doevents and margins of the main chart
No, it is not an error in TeeChart. The MSDN caution is quite clear. Calling Application.DoEvents() causes the current thread to be suspended, which for a Graphics application which depends on a running thread to do its calculations is bound to be problematic.wakeup wrote:It is only a example application to reproduce the problem I have in the real application, it is because the user adds the series, and after do other things it fills it with data. This is only a demonstration it is a error in the teechart.
If you were to call Application.DoEvents() *after* TeeChart has finished all its calculations, that is, when it has finished drawing, then this is likely to be much less problematic. As an example, the following code works without any unexpected behaviour:
Code: Select all
private void button10_Click(object sender, EventArgs e)
{
tChart1.AfterDraw += tChart1_AfterDraw;
Steema.TeeChart.Styles.Line line = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line.LinePen.Width = 2;
tChart1.Series.Add(line);
tChart1.Series[0].XValues.DateTime = true;
tChart1.Series[0].Add(new DateTime(2009, 7, 1, 0, 0, 0), 6525.4632);
tChart1.Series[0].Add(new DateTime(2009, 7, 1, 0, 30, 0), 6325.000016);
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
Application.DoEvents();
}
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Scrollpager doevents and margins of the main chart
Ok, forget doevents, it was only an example, it is not the main issue.
Please change my example, add a new button Button11 like this code. And press button10, then button11, and then button1... You have the same problem...
Please change my example, add a new button Button11 like this code. And press button10, then button11, and then button1... You have the same problem...
Code: Select all
private void button10_Click(object sender, EventArgs e)
{
Steema.TeeChart.Styles.Line line = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line.LinePen.Width = 2;
tChart1.Series.Add(line);
tChart1.Series[0].XValues.DateTime = true;
}
private void button11_Click(object sender, EventArgs e)
{
tChart1.Series[0].Add(new DateTime(2009, 7, 1, 0, 0, 0), 6525.4632);
tChart1.Series[0].Add(new DateTime(2009, 7, 1, 0, 30, 0), 6325.000016);
}
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Scrollpager doevents and margins of the main chart
Okay, I can see the problem now. It has nothing to do with the scrollpager tool. I have added it to our bugtracker with id=590.wakeup wrote:Please change my example, add a new button Button11 like this code. And press button10, then button11, and then button1... You have the same problem...
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Scrollpager doevents and margins of the main chart
FYI: this defect has now been fixed, and I've checked with your scrollpager code that all works as expected. Using Application.DoEvents also works as in your previous example of button10_Clickwakeup wrote:Ok. thanks
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Scrollpager doevents and margins of the main chart
Nice thanks a lot!