1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, StdCtrls,
Windows;
type
TMyMemo = class(TMemo)
protected
procedure WMSetFocus(var Msg: TWMSetFocus); message WM_SETFOCUS;
procedure WMKillFocus(var Msg: TWMKillFocus); message WM_KILLFOCUS;
end;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
MyMemo: TMyMemo;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
MyMemo := TMyMemo.Create(Self);
MyMemo.SetBounds(10, 10, 200, 150);
MyMemo.Parent := Self;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TMyMemo.WMSetFocus(var Msg: TWMSetFocus);
begin
inherited;
CreateCaret(Handle, HBITMAP(0), 10, 20);
ShowCaret(Handle);
end;
procedure TMyMemo.WMKillFocus(var Msg: TWMKillFocus);
begin
inherited;
DestroyCaret();
end;
end. |
Partager