unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TEdit=Class(StdCtrls.TEdit)
private
FReentranceProhibit:Boolean;
FOnSelChange:TNotifyEvent;
FoldSelLength,FOldSelStart:Integer;
public
procedure DefaultHandler(
var Message);
override;
published
Property OnSelChange:TNotifyEvent
read FOnSelChange
write FOnSelChange;
End;
TForm1 =
class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
procedure MySelchange(Sender: TObject);
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TEdit.DefaultHandler(
var Message);
begin
inherited;
if FReentranceProhibit
then exit
else
begin
FReentranceProhibit := true;
try
if Assigned(FOnSelChange)
and ((FOldSelStart<>SelStart)
or (FOldSelLEngth<>SelLength))
then
begin
FOnSelChange(Self);
end;
finally
FReentranceProhibit := false;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.OnSelChange := MySelchange;
Edit2.OnSelChange := MySelchange;
end;
procedure TForm1.MySelchange(Sender: TObject);
begin
Caption := Tedit(Sender).
Name+'
-' + IntToStr(TEdit(Sender).SelLength) +'
-' + IntToStr(TEdit(Sender).SelStart) ;
end;
end.