Solved

Component development in general

Posted on 2004-10-06
8
366 Views
Last Modified: 2013-11-23
This question is not about how to implement a TComponent descendant. I want to know more about the, err... philosophie of component development. The PME stuff (properties, methods, events), decoupling and so on. Any help or links apprechiated.
0
Comment
Question by:__alex
8 Comments
 
LVL 17

Assisted Solution

by:geobul
geobul earned 50 total points
ID: 12235479
Hi,

There is a help book in my D5 installation named 'Creating Custom Components'. Open it from Programs-Delphi-Help-'Creating Custom Components'.

Regards, Geo
0
 
LVL 6

Assisted Solution

by:pritaeas
pritaeas earned 50 total points
ID: 12235655
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 12236531
from Delphi:
Component / New Component
1) Ancestor type   : TComponent
2) Class Name : TMyNewComponent
the rest stays default. If you want, you can put your Pallete Page something like your name.
Press OK after that.

Delphi generate some code for your. I will put some basic properties and paste the example... In published section are the properties, you seen in object inspector

unit MyNewComponent;

interface

uses
  SysUtils, Classes, Controls, Messages;

type
  TMyNewComponent = class(TComponent)
  private
    // variable for event
    OnLButton   : TMouseEvent;
    // set procedure
    procedure SetLButton (const Value : TMouseEvent);
  protected
    procedure OnLeftButton (var Msg : TMessage); message WM_LBUTTONDOWN;
  public

  published
    // this property is already know, no need to declare
    property Name;
    // declare new event
    property OnLeftMouseButton : TMouseEvent read OnLButton write SetLButton;
  end;

procedure Register;

implementation

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

{ TMyNewComponent }

procedure TMyNewComponent.OnLeftButton(var Msg: TMessage);
begin
  // left mouse button is clicked
  if Assigned(OnLButton) then
    OnLButton(Self, mbLeft, [], 0, 0);
end;

procedure TMyNewComponent.SetLButton(const Value: TMouseEvent);
begin
  OnLButton := Value;
end;

end.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 9

Expert Comment

by:ginsonic
ID: 12237575
The book that come with Delphi CD is a good start to understand the vcl development.
0
 
LVL 11

Assisted Solution

by:robert_marquardt
robert_marquardt earned 50 total points
ID: 12237737
Have a look at the TLabel implementation. It is a good example on decoupling.
0
 
LVL 8

Accepted Solution

by:
BdLm earned 50 total points
ID: 12237956
components are an excellent way to reduce "double" coding, they help to keep the volume of your code small.
Its a very good way to ensure software quality.
before you write a program, think about the best way to define a object model for your data- and group
their functions and algorithms with components.
such programs will be easy to maintain and have the best options to enhance instead of re-writing from the scratch.
0
 
LVL 13

Expert Comment

by:BlackTigerX
ID: 12244144
components are very tied with OOP programming, here's all the concepts, etc of OOP

- Classes
- Design Patterns
- Owner and Parent
- Delphi OOP for beginners
- Run-Time Type Information (RTTI) In Delphi

among other things that you will find browsing through those links

http://delphi.about.com/od/oopindelphi/

and creating Delphi Components full tutorial:
http://delphi.about.com/library/bluc/text/uc061102a.htm
0
 
LVL 2

Author Comment

by:__alex
ID: 12246155
Thanks for the input!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Delphi selector screen 2 85
Delphi Yen format 3 45
Multi-layered image in FireMonkey 9 49
Why  'Host Connection unavailable/Socket Error #113 No route to host' 6 54
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

820 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