有几个朋友和同事问我怎样写控件,下面例子是派生一个Tedit;添加一个属性和一个鼠标右键单击事件. (0分)

  • 主题发起人 主题发起人 dcsdcs
  • 开始时间 开始时间
D

dcsdcs

Unregistered / Unconfirmed
GUEST, unregistred user!
有几个朋友和同事问我怎样写控件,下面例子是派生一个Tedit;
添加一个dcs:integer的属性和一个onrightclick(鼠标右键单击)的事件;
与大家共享!
unit DcsEdit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TDcsEdit1 = class(TEdit)
private
Frightclick:TnotifyEvent;//如果你需要在事件里面带参数,参看TnotifyEvent
Fdcs:integer;
procedure getrightclickmeg(VAR Msg:TMessage);message WM_RBUTTONDOWN;//捕获鼠标右键单击消息
function reddcs:integer;
procedure setdcs(input:integer);
protected
public
constructor Create(AWoner:TComponent);override;
destructor Destroy;override;
published
property dcs:integer read reddcs write setdcs ;
property Onrightclick:TnotifyEvent read Frightclick write Frightclick;
end;

procedure Register;

implementation
constructor TDcsEdit1.Create(AWoner:TComponent);
begin
inherited Create(AWoner);
end;
function TDcsEdit1.reddcs:integer;
begin
result:=Fdcs;
end;
procedure TDcsEdit1.setdcs(input:integer);
begin
Fdcs:=input;
end;
destructor TDcsEdit1.Destroy;
begin
inherited Destroy;
end;
procedure TDcsEdit1.getrightclickmeg(VAR Msg:TMessage);
begin
if Assigned(Frightclick) then
Frightclick(self);
end;
procedure Register;
begin
RegisterComponents('Samples', [TDcsEdit1]);
end;

end.
 
谢谢好心人[:)]
 
书上很多啊,没必要在这增加服务器的负担吧,我的邮件通知都出问题了[:(]
 
接受答案了.
 
后退
顶部