Einzelnen Beitrag anzeigen

Benutzerbild von Jens Schumann
Jens Schumann

Registriert seit: 27. Apr 2003
Ort: Bad Honnef
1.644 Beiträge
 
Delphi 2009 Professional
 
#4

Re: GetCursorPos in einem Edit

  Alt 6. Mai 2004, 19:49
Hallo,
versuch es doch mal so:
Delphi-Quellcode:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure Edit1Enter(Sender: TObject);
    procedure Edit1Change(Sender: TObject);
    procedure Edit1Click(Sender: TObject);
  private
    { Private-Deklarationen }
    FTimeStamp : String;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  FTimeStamp:=DateToStr(Now)+' '+TimeToStr(Now)+': ';
  Edit1.Text:=FTimeStamp;
end;

procedure TForm1.Edit1Enter(Sender: TObject);
begin
  Edit1.SelStart:=Length(FTimeStamp);
end;

procedure TForm1.Edit1Change(Sender: TObject);
begin
  If (Length(Edit1.Text)<Length(FTimeStamp)) or
     (Edit1.SelStart<Length(FTimeStamp)) then
    begin
    Edit1.Text:=FTimeStamp;
    Edit1.SelStart:=Length(FTimeStamp);
    end;
end;

procedure TForm1.Edit1Click(Sender: TObject);
begin
  If Edit1.SelStart<Length(FTimeStamp) then
    Edit1.SelStart:=Length(FTimeStamp);
end;

end.
I come from outer space to save the human race
  Mit Zitat antworten Zitat