📄 colourlabel.pas
字号:
unit ColourLabel;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TColourLabel = class(TLabel)
private
{ Private declarations }
g_color:Tcolor;
procedure ColourLabelMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure ColourLabelMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent);override;
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TColourLabel]);
end;
constructor TColourLabel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Cursor:=crHandPoint;
Font.Color:=ClBlue;
Font.Style:=[fsUnderLine];
OnMouseDown:=ColourLabelMouseDown;
OnMouseUp:=ColourLabelMouseUp;
end;
//
procedure TColourLabel.ColourLabelMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
g_color:=Color;
Color:=clBlack;
Font.Color:=ClYellow;
end;
//
procedure TColourLabel.ColourLabelMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Color:=g_color;
Font.Color:=ClBlue;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -