Page 1 of 1

Exception on the event OnGetAxisLabel

Posted: Tue Mar 07, 2006 8:53 am
by 9339785
hi,
I try to use the event OnGetAxisLabel in my application, but when this event is generated an exception is raised when I try to read the string "LabelText".
I found the problem : in my project options I'm not using the option "huge strings", which corresponds to {$H-}.
how can I bypass this problem ?
Thanks

Franck

Posted: Tue Mar 07, 2006 9:35 am
by narcis
Hi Franck,

I've been able to reproduce that. TeeChart needs "Huge Strings" so to work it around you can do something like the code below forcing the use of "Huge Strings" before executing the GetAxisLabel event.

Code: Select all

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, TeEngine, Series, ExtCtrls, TeeProcs, Chart;

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Series1: TLineSeries;
    {$H+}
    procedure Chart1GetAxisLabel(Sender: TChartAxis; Series: TChartSeries;
      ValueIndex: Integer; var LabelText: String);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
begin
  LabelText:='abc';
end;

end.

Posted: Tue Mar 07, 2006 9:55 am
by 9339785
What do you mean exactly by "TeeChart needs Huge Strings" ?
In my application I definitively can not set "huge strings" option in the project options of the application, does it mean that TeeChart will not work correctly without this option ?
What problems will I encounter ?

Posted: Tue Mar 07, 2006 10:03 am
by narcis
Hi Franck,

TeeChart needs "Huge Strings" because it uses several PChar castings. If you disable "Huge Strings" your application with TeeChart may not run, depending on the features you use. However, you can enable/disable "Huge Strings" doing something like this:

Code: Select all

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, TeEngine, Series, ExtCtrls, TeeProcs, Chart;

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Series1: TLineSeries;
    procedure Chart1GetAxisLabel(Sender: TChartAxis; Series: TChartSeries;
      ValueIndex: Integer; var LabelText: {$H+}String{$H-});
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: {$H+}String{$H-});
begin
  LabelText:='abc';
end;

end.
However, not using "Huge Strings" may lead you to several other problems in Delphi. Our suggestion is to do the opposite, disable them when you don't want to use them.