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
LVL 4
itamarAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ZifNabConnect With a Mentor Commented:
Hi itamar,

It's simple :

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
uses EditChar;   <---------------------!!!!
{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
EditChart(Self,Chart1 );  
end;

end.


---

(if you use DBChart components)


 Uses DBEditCh;
 EditChart(Self,DBChart1 );

Regards, Zif.
0
 
itamarAuthor Commented:
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
0
 
itamarAuthor Commented:
Hi Zif.

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

Any ideas ???

[]´s
Itamar
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
ZifNabCommented:
strange, I tried it out on D4 on my office and it worked. Can you give me your source-code?
0
 
itamarAuthor Commented:
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
0
 
ZifNabCommented:
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.
0
 
itamarAuthor Commented:
Zif,

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

Thanks,

Itamar
0
 
ZifNabCommented:
Great!
0
 
itamarAuthor Commented:
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
0
 
ZifNabCommented:
Hi itamar,

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

Zif.
0
 
itamarAuthor Commented:
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.
0
 
ZifNabCommented:
sorry itamar, I'm stuck at the moment too.
0
 
SaxonCommented:
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
0
 
nezeqcatCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.