Teechart V 3 crashes on hide and unhide of containing window

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Srinivas Avancha
Newbie
Newbie
Posts: 41
Joined: Wed Jan 30, 2008 12:00 am

Teechart V 3 crashes on hide and unhide of containing window

Post by Srinivas Avancha » Fri Mar 14, 2008 1:16 pm

Steps to recreate
1) The chart control is hidden to begin with and the containing (tabbed mdi child) window is not.
2) The containing (tabbed mdi child) window is hidden and then unhidden.
3) The chart control is unhidden when the containing (tabbed mdi child) window is activated by clicking on the tab.
4) The chart control is hidden when the containing (tabbed mdi child) window is deactivated by clicking on a different tab.
5) The containing (tabbed mdi child) window is hidden and then unhidden.
6) The chart control is unhidden when the containing (tabbed mdi child) window is activated by clicking on the tab.

You will get the error "System.ArgumentException: Parameter is not valid.
" on windows xp professional, call stack is provided below. On Vista 64 you will get “The Red X”.

Note: 1) Used Infragistics.Win.UltraWinTabbedMdi.UltraTabbedMdiManager for the tabs.
2)Teechart V2 works like a charm, it’s the Teechart V3 that crashes.


System.ArgumentException: Parameter is not valid.
at System.Drawing.Graphics.GetHdc()
at System.Drawing.BufferedGraphics.Render(Graphics target)
at System.Drawing.BufferedGraphics.Render()
at Steema.TeeChart.TChart.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Mar 14, 2008 1:57 pm

Hi Srinivas,

Would you be so kind to send us a simple example project we can run "as-is" to reproduce the problem here and let us know the exact TeeChart version you are using?

You may be also interested in checking this recent issue related to the use of TeeChart together with Infragistics components.

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Srinivas Avancha
Newbie
Newbie
Posts: 41
Joined: Wed Jan 30, 2008 12:00 am

Post by Srinivas Avancha » Fri Mar 14, 2008 2:12 pm

The Version of TeeChart is 3.2.2980.19083. I will try to create a simplistic sample. Please let me know if you were able to reproduce on your side in the meantime.

The link to first time exception does not address our problem.

Srinivas Avancha
Newbie
Newbie
Posts: 41
Joined: Wed Jan 30, 2008 12:00 am

Post by Srinivas Avancha » Tue Mar 18, 2008 2:36 pm

Hi Narcís,

Loaded the zip containing the project that throws the error.
1) Add atleast 3 tabs.
2) Hide a Tab.
3 Unhide a Tab and you should see the error.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Mar 19, 2008 11:41 am

Hi Srinivas,

Thank you very much for the example project. This certainly helped reproducing the issue here. You can solve it setting tChart1.Chart.Graphics3D.BackBuffer = null; when changing tabs, for example:

Code: Select all

        private void Chart_Activated(object sender, EventArgs e)
        {
            tChart1.Chart.Graphics3D.BackBuffer = null;
            tChart1.Visible = true;
        }

        private void Chart_Deactivate(object sender, EventArgs e)
        {
            tChart1.Chart.Graphics3D.BackBuffer = null;
            tChart1.Visible = false;
        }
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

lolo31
Newbie
Newbie
Posts: 3
Joined: Wed Sep 19, 2007 12:00 am

Post by lolo31 » Wed Mar 19, 2008 12:30 pm

Hi,

I have the same error with the chart in a dialog box (at the second call of the box).

So, I have add "Chart1.Chart.Graphics3D.BackBuffer = Nothing" in the Form_Load to workaround...

Regards.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Mar 19, 2008 12:34 pm

Hi lolo31,

Would you be so kind to also send a sample project we can run "as-is" to investigate the issue here?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

lolo31
Newbie
Newbie
Posts: 3
Joined: Wed Sep 19, 2007 12:00 am

Post by lolo31 » Wed Mar 19, 2008 12:47 pm

Sorry but I can't access to newsgroup or upload page from my Office.

It's very simple to do:
1) Create a new project with Form1
2) Add a new Form2
3) Put a button on Form1 and add "Form2.showDialog()" in the Button_Click
4) On the Form2, put a chart and a button to close the form

Run and open twice the Form2.

NB: The Version of TeeChart is 3.2.2980.19082 on Visual Studio.Net 2005 SP1

Regards.

Srinivas Avancha
Newbie
Newbie
Posts: 41
Joined: Wed Jan 30, 2008 12:00 am

Post by Srinivas Avancha » Wed Mar 19, 2008 1:11 pm

Thank You Narcís, it worked.

I guess this is a workaround as it is perfectly working without BackBuffer = null in V2. Will you be fixing this in next release of V3?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Mar 19, 2008 2:58 pm

Hi lolo31,
lolo31 wrote:Sorry but I can't access to newsgroup or upload page from my Office.

It's very simple to do:
1) Create a new project with Form1
2) Add a new Form2
3) Put a button on Form1 and add "Form2.showDialog()" in the Button_Click
4) On the Form2, put a chart and a button to close the form

Run and open twice the Form2.

NB: The Version of TeeChart is 3.2.2980.19082 on Visual Studio.Net 2005 SP1

Regards.
Thanks for the information. It seems we are having some problems with www.steema.net server :(.

I've made a project like you reported but I'm not able to reproduce the problem here. The steps I followed are:

1. Run the application.
2. Click the button in Form1 to open Form2.
3. Close Form2 instance.
4. Click the button in Form1 to open Form2.
5. Close Form2 instance.

Form1 code:

Code: Select all

    public partial class Form1 : Form
    {
        public Form1()
        {
          InitializeComponent();
        }

      private void button1_Click(object sender, EventArgs e)
      {
        Form2 f = new Form2();
        f.ShowDialog();
      }
    }
Form2 code:

Code: Select all

  public partial class Form2 : Form
  {
    public Form2()
    {
      InitializeComponent();

      Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
      line1.FillSampleValues();
    }

    private void button1_Click(object sender, EventArgs e)
    {
      this.Close();
    }
  }
Can you please confirm those are the correct steps to reproduce the issue?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

lolo31
Newbie
Newbie
Posts: 3
Joined: Wed Sep 19, 2007 12:00 am

Post by lolo31 » Wed Mar 19, 2008 3:32 pm

Your code works because you have a "New" each time you open Form2.
In VB, you don't have to do the "New" and that cause the issue.
(In the second call, the form is in memory)

Regards.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Mar 19, 2008 3:50 pm

Hi lolo31,

Using VB I need to do as shown below and the problem doesn't occur either.

Form1:

Code: Select all

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim f As New Form2
        f.ShowDialog()
    End Sub
End Class
Form2:

Code: Select all

Public Class Form2

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Close()
    End Sub

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim line1 As New Steema.TeeChart.Styles.Line(TChart1.Chart)
        line1.FillSampleValues()
    End Sub
End Class
How do you think I should modify the code to reproduce the issue here?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

lolo31
Newbie
Newbie
Posts: 19
Joined: Thu Mar 25, 2004 5:00 am

Post by lolo31 » Wed Mar 19, 2008 3:53 pm

Replace :

Dim f As New Form2
f.ShowDialog()

By:

Form2.ShowDialog()

Regards.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Mar 20, 2008 10:07 am

Hi lolo31,

This doesn't seem correct to me as ShowDialog is not a static method I don't think it should be directly called from the class.

Anyway, if you wish to continue working that way you don't need to set BackBuffer to Nothing as reseting the chart (TChart1.Clear) works fine as well:

Code: Select all

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TChart1.Clear()
        'TChart1.Chart.Graphics3D.BackBuffer = Nothing

        Dim line1 As New Steema.TeeChart.Styles.Line(TChart1.Chart)
        line1.FillSampleValues()
    End Sub
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Mar 20, 2008 10:43 am

Hi Srinivas,
Srinivas wrote:Thank You Narcís, it worked.

I guess this is a workaround as it is perfectly working without BackBuffer = null in V2. Will you be fixing this in next release of V3?
We don't consider this to be a bug in v3. It's because of the implementation of manual doublebuffering feature as you can read here.

If you don't want to set BackBuffer to null you can also set UseBuffer property to false:

Code: Select all

	public partial class Chart : Form
	{
		public Chart()
		{
			InitializeComponent();
		}

		private void Chart_Load(object sender, EventArgs e)
		{
			fastLine1.FillSampleValues();
			fastLine2.FillSampleValues();
			fastLine3.FillSampleValues();

			tChart1.Graphics3D.UseBuffer = false;
		}

		private void Chart_Activated(object sender, EventArgs e)
		{
			//tChart1.Chart.Graphics3D.BackBuffer = null;
			tChart1.Visible = true;
		}

		private void Chart_Deactivate(object sender, EventArgs e)
		{
			//tChart1.Chart.Graphics3D.BackBuffer = null;
			tChart1.Visible = false;
		}
	}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply