Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Create component

Posted on 2002-04-22
6
Medium Priority
?
235 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 1200 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

670 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