Solved

Create component

Posted on 2002-04-22
6
226 Views
Last Modified: 2010-04-04
// --- Create component ---
// I don't know how to create component with this informations
// I want that my new component can add, insert, delete, and other
// functions that are in TComponentList, but with A1, A2, A3, A4, A5, A6

// Thanks.

unit PropertyComponentList;

interface

uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Menus, StdCtrls, Dialogs, Contnrs;
                                   
type
  PPropertyList = ^AComponentList;
  AComponentList = record
    A1 : Boolean;
    A2 : TStrings;
    A3 : String;
    A4 : TStrings;
    A5 : TStrings;
    A6 : TStrings;
  end;

implementation

procedure Register;
begin
                                   
RegisterComponents('Samples', [PPropertyList]);

end;

end.
0
Comment
Question by:ghjlk
6 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6959468
? could you explain the sense
(thats above is definitivly wrong)
0
 
LVL 7

Expert Comment

by:God_Ares
ID: 6959516
Well I don't quite know what you ment

but i can tell you you should alway's create a component by using a class. If you want a non visual component i would recomend to derive you component form tcomponent, in code:

Type
  TMyComponent = class(Tcomponent)
  Private
    { Private declarations }
  Public
    { Public declarations }
  End;


If you'll be so kind and tell us some more what you want.
0
 
LVL 1

Accepted Solution

by:
Alone earned 300 total points
ID: 6959844
type
  TMyComponent = class(TComponent)
  private
    FA1 : Boolean;
    FA2 : TStrings;
    FA3 : string;
    FA4 : TStrings;
    FA5 : TStrings;
    FA6 : TStrings;
    procedure SetA2(Value: TStrings);
    procedure SetA4(Value: TStrings);
    procedure SetA5(Value: TStrings);
    procedure SetA6(Value: TStrings);
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    property A1: Boolean read FA1 write FA1 default False;
    property A2: TStrings read FA2 write SetA2;
    property A3: string read FA3 write FA3;
    property A4: TStrings read FA4 write SetA4;
    property A5: TStrings read FA5 write SetA5;
    property A6: TStrings read FA6 write SetA6;
  end;

{ TMyComponent }

constructor TMyComponent.Create(AOwner: TComponent);
begin
  inherited; // default constructor fill all the instance with 0
  FA2 := TStringList.Create;
  FA4 := TStringList.Create;
  FA5 := TStringList.Create;
  FA6 := TStringList.Create;
end;

destructor TMyComponent.Destroy;
begin
  FA6.Free;  // LIFO method recommended for destructors to aviod
  FA5.Free;  // stupid errors
  FA4.Free;
  FA2.Free;
  inherited;
end;

procedure TMyComponent.SetA2(Value: TStrings);
begin
// using of TPersistent.Assign needed for all non-component properties
// to aviod memory leaks and access violations
  if FA2 <> Value then FA2.Assign(Value);
end;

procedure TMyComponent.SetA4(Value: TStrings);
begin
  if FA4 <> Value then FA4.Assign(Value);
end;

procedure TMyComponent.SetA5(Value: TStrings);
begin
  if FA5 <> Value then FA5.Assign(Value);
end;

procedure TMyComponent.SetA6(Value: TStrings);
begin
  if FA6 <> Value then FA6.Assign(Value);
end;

Did I right understood you? ;-)

WBR...
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Expert Comment

by:lottol
ID: 6959861
It's problematically to cover all spects of component creating in this thread.
You'd better to read some tutorial about components writing.
if you have Delphi 5, there is DeveloperGuide.pdf file, which is installed with Delphi.
Also this subject is covered in Delphi Help node "Creating Custom Components"
Also it can be downloaded here ftp://ftp.borland.com/pub/delphi/techpubs/delphi5/d5cw.zip

You can find sources for different versions, but general concepts'd be the same.
0
 

Author Comment

by:ghjlk
ID: 6960091
I tried to create component for putting property in it's variebles like in stringgrid. I need 6 dimensinal list (component). In wich I'll put properties of program parts.

The propeties are :
  A1 : Boolean;
  A2 : TStrings;
  A3 : String;
  A4 : TStrings;
  A5 : TStrings;
  A6 : TStrings;

Thanks.
0
 
LVL 1

Expert Comment

by:Alone
ID: 6960688
Do you need a 6-dimensional data array? What's type of your data? Please describe some details of your task.
Otherwise, try to copy/paste my code into unit and then register new TMyComponent. It's fully functional.

WBR...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Syntax Check Delphi Seattle IOS app without MAC ? 1 91
Newbie Thread Programming 1 139
FMX StringGrid1->Canvas->FillRect Problem 3 127
Delphi 2 47
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now