Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

custom component OnClick event 1

Status
Not open for further replies.

rkamarowski

Programmer
Apr 23, 2007
16
US
i've created a custom component, but i'm unable to get the buttonFind.OnClick event to work. i'm getting an 'incompatible type' error. any help would be appreciated.

here's the code:

=================
unit KMPDGlobalLister;

interface

uses
SysUtils, Classes, ComCtrls, Controls, ExtCtrls,
Dialogs, StdCtrls, Trpcb, ToolWin, MFunStr;

type
TKMPDGlobalLister = class(TPanel)
private
{ Private declarations }
function GetGlobalName: string;
function GetLastNodeAccessed: string;
procedure buttonMoreClick(sVal: String);
procedure SetGlobalName(sVal: string);
procedure SetLastNodeAccessed(sVal: string);
protected
{ Protected declarations }
procedure buttonFindClick();
public
{ Public declarations }
buttonFind: TButton;
buttonMore: TButton;
editGlobalName: TEdit;
labelGlobalName: TLabel;
// properites
property GlobalName: string read GetGlobalName write SetGlobalName;
property LastNodeAccessed: string read GetLastNodeAccessed write SetLastNodeAccessed;
// methods
Constructor Create(AnOwner:TComponent); Override;
Destructor Destroy; Override;
published
{ Published declarations }
panelTools: TPanel;
memoGlobalLister: TMemo;
FRpcBroker: TRPCBroker;
property RpcBroker: TRPCBroker read FRpcBroker write FRpcBroker;

end;

procedure Register;

implementation

Constructor TKMPDGlobalLister.Create(AnOwner:TComponent);
begin
inherited Create(AnOwner);
Align:=alClient;
Anchors:=[akLeft,AkRight,akTop,akBottom];
Height:=200;
Width:=200;

panelTools:=TPanel.Create(Self);
with panelTools do
begin
...
panelTools.Show;

labelGlobalName:=TLabel.Create(Self);
with labelGlobalName do
begin
...
end;
labelGlobalName.Show;


editGlobalName:=TEdit.Create(Self);
with editGlobalName do
begin
...
end;
editGlobalName.Show;

buttonFind:=TButton.Create(panelTools);
with buttonFind do

begin
Align:=alLeft;
Caption:='Find';
Enabled:=true;
Onclick:=buttonFindClick;
Parent:=panelTools;
Visible:=true;
end;
buttonFind.show;

buttonMore:=TButton.Create(panelTools);
with buttonMore do
begin
...
end;
buttonMore.show;


// memo for text
memoGlobalLister:=Tmemo.Create(Self);
memoGlobalLister.Parent:=Self;
with memoGlobalLister do
begin
...
end;
memoGlobalLister.Show;

end; // constructor

Destructor TKMPDGlobalLister.Destroy;
begin
inherited Destroy;
end;

// functions and procedures
function TKMPDGlobalLister.GetGlobalName: string;
begin
result:=GlobalName;
end;

function TKMPDGlobalLister.GetLastNodeAccessed: string;
begin
result:=LastNodeAccessed;
end;

procedure TKMPDGlobalLister.buttonFindClick();
begin
MessageDlg('click',mtError,[mbOK],0);

if editGlobalName.Text='' then exit;
SetGlobalName(editGlobalName.Text);
SetLastNodeAccessed('');
buttonMore.Enabled:=false;
memoGlobalLister.Clear;
buttonMoreClick(GetGlobalName);
end;


procedure TKMPDGlobalLister.buttonMoreClick(sVal: string);
begin

if sVal='' then exit;
...
end;


procedure TKMPDGlobalLister.SetGlobalName(sVal: string);
begin
GlobalName:=sVal;
end;

procedure TKMPDGlobalLister.SetLastNodeAccessed(sVal: string);
begin
LastNodeAccessed:=sVal;
end;

procedure Register;
begin
RegisterComponents('Capacity Planning', [TKMPDGlobalLister]);
end;

end.

 
OnClick event must be of the type TNotifyEvent which means the parameters of the method you assign to the OnClick event must be in the form of
Code:
procedure MyOnClickEvent(Sender: TObject);

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top