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