-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbLink.pas
81 lines (66 loc) · 1.88 KB
/
bLink.pas
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
unit bLink;
interface
uses
Windows, Messages, Classes, Graphics, Controls, Forms, StdCtrls, SysUtils,
ShellAPI;
type
TbLink = class(TLabel)
private
FFocusFont, FSaveFont: TFont;
FOnMouseEnter, FOnMouseLeave: TNotifyEvent;
procedure SetFocusFont(Value: TFont);
protected
procedure CMMouseEnter(var Msg: TMessage); message CM_MouseEnter;
procedure CMMouseLeave(var Msg: TMessage); message CM_MouseLeave;
public
constructor Create(aOwner : TComponent); override;
destructor Destroy; override;
procedure SetNewFont(Value: TFont);
published
property FocusFont: TFont read FFocusFont write SetFocusFont;
property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
end;
procedure Register;
implementation
constructor TbLink.Create(aOwner: TComponent);
begin
inherited Create(aOwner);
FFocusFont := TFont.Create;
FSaveFont := TFont.Create;
FSaveFont.Assign(Font);
Cursor:= crHandPoint;
end;
destructor TbLink.Destroy;
begin
FSaveFont.Free;
FFocusFont.Free;
inherited Destroy;
end;
procedure TbLink.CMMouseEnter(var Msg: TMessage);
begin
if csDesigning in ComponentState then Exit;
if FSaveFont <> Font then FSaveFont.Assign(Font);
Font.Assign(FFocusFont);
if Assigned(FOnMouseEnter) then OnMouseEnter(Self);
end;
procedure TbLink.CMMouseLeave(var Msg: TMessage);
begin
if csDesigning in ComponentState then Exit;
Font.Assign(FSaveFont);
if Assigned(FOnMouseLeave) then OnMouseLeave(Self);
end;
procedure TbLink.SetFocusFont(Value: TFont);
begin
FFocusFont.Assign(Value);
end;
procedure TbLink.SetNewFont(Value: TFont);
begin
Font:= Value;
FSaveFont.Assign(Value);
end;
procedure Register;
begin
RegisterComponents('Samples', [TbLink]);
end;
end.