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