STEPs of creating a simple component(50分)

O

ourself

Unregistered / Unconfirmed
GUEST, unregistred user!
Hi All,

I am new to writing Delphi component, and would like to learn the STEPS of
creating components (Delphi 6.0 professional).

What I would like to do is to add code to the standard button, so that when the
user click on the button, it will trigger: beep; (or showMessage('Hi');).
The following steps are what I have done:

1. close all projects, click File->New->Others->components

2. In the new component dialog box select:
Ancestor type = TButton[StdCtrls]
Class name = testing
Pallete page = Samples
Unit file name = 'H:/Delphi/01/component2/Button1.pas'
Search path = default

3. Click OK

4. Now I am in a unit file, showing as below:

{code as below}
unit Button1;

interface

uses
Windows, Messages, SysUtils, Classes, Controls, StdCtrls;

type
TButton1 = class(TButton)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('samples', [TButton1]);
end;

end.

Questions:
1. Where should I add the beep, or showMessage('Hi');?
2. In additional to 'dclusr.dpk', can we create own dpk files?
3. I have tried using showMessage('Hi'); and it has an error. Does it mean
that I have to add 'use dialogs' in the uses section?


Thank you very much in advance!

PS.
Havn't got a chinese editor at work, and had to post the question in English.
 
1.public
procedure Click; override;
2.click component->Install NewComponent...
select 'IntoNewPackge' on the Tabsheet....
type the packge name in the 'packge file name:' EditBox
3. yes .

ps:my english is poor ,so you will have a hard read ^-^!
 
Hi,

I posted this question on http://www.experts-exchange.com, and within 1 hour,
already got a proper solution. However, if anyone would like to carry on the
discussion (I have to say it might be ridiculously simple to some genius),
feel free to join in. I will finish this question in about 2 days, after
giving out points to the relevant answers.

Thank you for your participation,

Cheers!
 
agree JobsLee
 
多人接受答案了。
 
顶部