HsWong() 昨天的问题还没有明白可以跟你详谈吗?
首先感谢您,昨天的问题您给我的帮助,可是我还是不明白您的指点不知道能不能详细解答!谢谢
或者通过MSN跟你请教,我的MSN:sunweikey@qingdaonews.com
[解决办法]
你那个OnCodeClick其实就是按钮FCodeButton的OnClick事件,所以
当触发FCodeButton的Click事件时,返回的Sender当然是FCodeButton了。
要想Sender变成TCodeEdit,即需要在程序中转一下:
TCodeEdit = class(TCustomMemo)
private
FOnCodeClick:TNotifyEvent;
procedure OnButtonClick(Sender:TObject); //定义FOnCodeClick的OnClick处理方法
public
constructor Create(AOwner: TComponent); override;
published
property OnCodeClick: TNotifyEvent read FOnCodeClick write FOnCodeClick;
implementation
constructor Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Height := 22; Width := 121;
WordWrap := False; WantReturns := False;
Useable := True;
FCodeButton := TSpeedButton.Create(Self);
with FCodeButton do begin
Parent := self;
Align := alRight;
Width := Width -1;
Glyph.LoadFromResourceName(HInstance, 'CODEEDIT ');
OnClick:=OnButtonClick; //按钮的OnClick事件处理方法为OnButtonClick;
end;
procedure OnButtonClick(Sender:TObject);
begin
if Assigned(FOnCodeClick) then FOnCodeClick(Self); //这里中转
end;
end;