Solved

Create component

Posted on 2002-04-22
6
231 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month8 days, 1 hour left to enroll

617 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