Solved

Component development in general

Posted on 2004-10-06
8
364 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
 
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
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.

 
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

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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…

863 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

27 Experts available now in Live!

Get 1:1 Help Now