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 FormDestroy(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
oldMemoProc: Pointer;
function NewEditWndProc(Wnd: hWnd; wMsg: DWORD; ParamW: WParam;
ParamL: LParam): LongInt;
stdcall;
var
edRect: TRect;
begin
NewEditWndProc := CallWindowProc(oldMemoProc, Wnd, wMsg, ParamW, ParamL);
Case wMsg
of
WM_SETFOCUS:
begin
GetClientRect(Wnd, edRect);
CreateCaret(Wnd, 0, 8, edRect.Bottom - 2);
ShowCaret(Wnd);
end;
WM_KILLFOCUS:
begin
HideCaret(Wnd);
DestroyCaret;
end;
end;
end;
// ---------------------------------------------------------------------------
procedure TForm1.FormCreate(Sender: TObject);
begin
oldMemoProc := Pointer(SetWindowLong(Edit1.Handle, GWL_WNDPROC, LongInt(@NewEditWndProc)));
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
//
end;