Solved

Component development in general

Posted on 2004-10-06
8
369 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
[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
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
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 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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month3 days, 19 hours left to enroll

630 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