Link to home
Start Free TrialLog in
Avatar of itamar
itamar

asked on

Exposing "Edit chart..." in a TChart wrapper...

Hi all,

i´m writting a component that is a Panel with a TChart, a ToolBar and some buttons inside.

The TChart´s owner is the component (TPanel descendant) itself, but I would like to allow the users to use the "Edit chart" feature like when right-clicking in the TChart component.

I think I have to create and register a component editor to my component and writ some code in ExecuteVerb method, but what code would  call TChart component editor.

I´m using D4 C/S.

TIA,
Itamar
ASKER CERTIFIED SOLUTION
Avatar of ZifNab
ZifNab

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of itamar
itamar

ASKER

Hi zif !

thanks for the fast response. In fact I will expose it in design-time. But the main code is here in your answer.

Regards,
Itamar
Avatar of itamar

ASKER

Hi Zif.

I graded your answer before testing it ! Now, I got the message "File not found: IEdiSeri.dcu"

Any ideas ???

[]´s
Itamar
strange, I tried it out on D4 on my office and it worked. Can you give me your source-code?
Avatar of itamar

ASKER

Hi Zif,

It´s a copy & Paste of your code. Perhaps the problem is Delphi version.


My version is 4.0 (Build 5.104) Update Pack 2.

Your version is the same ?

Itamar
I've the D4 Pro version update 3
(build 5.108)

I also have the Pro TeeChart installed. But this should be normal the same as with the standard components. Because the extra components (of the Pro version) are placed on another tab.

Don't you have the missing file installed in the lib directory of delphi?


Zif.
Avatar of itamar

ASKER

Zif,

i´ve downloaded the newest version of TChart and everything is working fine now.

Thanks,

Itamar
Great!
Avatar of itamar

ASKER

Hi ZIF !

it´s me again !

I told you everything was working fine, well, I lied ;)))

In fact, the Chart editor is starting, but when I add a serie, the editor doesn´t "write" the Series1 declaration in source code as it usually does outside of my component. I´d really apreciate if you could help me further. I´m really stucked in this problem.

I can send a simple (not) working example of my component.

TIA,
Itamar
Hi itamar,

just send the example over and I'll look what I can do,

Zif.
Avatar of itamar

ASKER

Hi Zif,

this is an example of my component:

>>>>>>

unit UTest;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Menus, ToolWin, ComCtrls, ExtCtrls, ImgList, stdCtrls, Spin, teeprevi,
  chart, series, DsgnIntf, EditChar;

type
    TTestEditor = class(TComponentEditor)
       function GetVerbCount: integer; override;
       function GetVerb(index: integer): string; override;
       procedure ExecuteVerb(Index: integer); override;
       procedure Edit; override;
    end;

type
  TTest = class(TPanel)
  private
    IPBarra     : TToolBar;
    btnTest : TToolButton;
    procedure TestClick( Sender: TObject );
  protected
    { Protected declarations }
  public
    grfGraf     : TChart;
    constructor Create(AOwner: TComponent); override;
    destructor destroy; override;
  published
    { Published declarations }
  end;

procedure Register;

implementation

{$R *.res}

procedure Register;
begin
     RegisterComponents('itamar', [TTest]);
     RegisterComponentEditor(TTest, TTestEditor);
end;

constructor TTest.Create(AOwner : TComponent);
begin
     inherited Create (AOwner);

     Self.Parent := TWinControl(AOwner);
     grfGraf     := TChart.Create(Self);
     IPBarra     := TToolBar.Create(Self);
     btnTest     := TToolButton.Create(Self);

     grfGraf.Parent       := Self;
     grfGraf.Align        := alClient;

     IPBarra.Parent      := Self;
     IPBarra.EdgeBorders := [ebTop, ebBottom];

     btnTest.Parent     := IPBarra;
     btnTest.Name       := 'btnTest';
     btnTest.Hint       := 'Test';
     btnTest.Left       := 0;
     btnTest.ImageIndex := 0;
     btnTest.ShowHint   := True;
     btnTest.OnClick    := TestClick;
end;

destructor TTest.destroy;
begin
     inherited;
end;

procedure TTest.TestClick( Sender: TObject );
begin
   Self.grfGraf.View3D := not Self.grfGraf.View3D;
end ;


{ //////  TTestEditor ///////}

procedure TTestEditor.Edit;
begin
   ExecuteVerb(0);
end;

procedure TTestEditor.ExecuteVerb(Index: integer);
begin
   case Index of
      0: begin
            EditChart(TForm(Component.Owner), TCustomChart(TTest(Component).grfGraf));
            Designer.Modified;
         end;
   end;
end;

function TTestEditor.GetVerb(index: integer): string;
begin
   case index of
      0: Result := 'Editar grafico';
   end;
end;

function TTestEditor.GetVerbCount: integer;
begin
     Result := 1;
end;

end.
sorry itamar, I'm stuck at the moment too.
I´ve got the same prob as you. The solution of Zif seems simple but doesn´t work, because I get the fatal compiler error: file not found: IEditCha.dcu (regarding EditChar in the uses part)
Do you know, whats the rason for it?
I´m using D5 with TeeChart Pro 4.02
Thx
About IEditCha.dcu. May be someone will need it:
The IEditCha.dcu is part of Runtime package TEEUI50.BPL
In order to resolve problem "I get the fatal compiler error: file not found: IEditCha.dcu" add it to application this way:
To use a custom runtime package with an application, choose Project|Options and add the name of the package (TEEUI50) to the Runtime Packages edit box on the Packages page.
Now you can enjoy the Tee Chart Editor