Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Component development in general

Posted on 2004-10-06
8
Medium Priority
?
374 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 200 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 200 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
Industry Leaders: 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!

 
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 200 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 200 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

Industry Leaders: 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!

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Loops Section Overview
Suggested Courses

772 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