unit ShadowLabel; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TShadowLabel = class(TCustomLabel) private FShadowColor: TColor; FSE: Boolean; procedure SetFSE(SE: Boolean); procedure SetSColor(C: TColor); protected procedure DoDrawText(var Rect: TRect; Flags: Longint); override; public constructor Create(AOwner: TComponent); override; published property Align; property Alignment; property Anchors; property AutoSize; property BiDiMode; property Caption; property Color; property Constraints; property DragCursor; property DragKind; property DragMode; property Enabled; property FocusControl; property Font; property ParentBiDiMode; property ParentColor; property ParentFont; property ParentShowHint; property PopupMenu; property ShowAccelChar; property ShowHint; property ShadowColor: TColor read FShadowColor write SetSColor; property ShadowEnabled: Boolean read FSE write SetFSE; property Transparent; property Layout; property Visible; property WordWrap; property OnClick; property OnDblClick; property OnDragDrop; property OnDragOver; property OnEndDock; property OnEndDrag; property OnMouseDown; property OnMouseMove; property OnMouseUp; property OnStartDock; property OnStartDrag; end; procedure Register; implementation procedure Register; begin RegisterComponents('Samples', [TShadowLabel]); end; constructor TShadowLabel.Create(AOwner: TComponent); begin FShadowColor := clGray; FSE := True; inherited Create(AOwner); end; procedure TShadowLabel.SetFSE(SE: Boolean); begin if SE <> FSE then begin FSE := SE; ReFresh; end; end; procedure TShadowLabel.SetSColor(C: TColor); begin if FShadowColor <> C then begin FShadowColor := C; ReFresh; end; end; procedure TShadowLabel.DoDrawText(var Rect: TRect; Flags: Longint); var Text: string; begin Text := GetLabelText; if (Flags and DT_CALCRECT <> 0) and ((Text = '') or ShowAccelChar and (Text[1] = '&') and (Text[2] = #0)) then Text := Text + ' '; if not ShowAccelChar then Flags := Flags or DT_NOPREFIX; Flags := DrawTextBiDiModeFlags(Flags); Canvas.Font := Font; if not Enabled then begin OffsetRect(Rect, 1, 1); Canvas.Font.Color := clBtnHighlight; DrawText(Canvas.Handle, PChar(Text), Length(Text), Rect, Flags); OffsetRect(Rect, -1, -1); Canvas.Font.Color := clBtnShadow; DrawText(Canvas.Handle, PChar(Text), Length(Text), Rect, Flags); end else begin OffsetRect(Rect, 1, 1); Canvas.Font.Color := FShadowColor; if FSE then begin DrawText(Canvas.Handle, PChar(Text), Length(Text), Rect, Flags); end; Canvas.Font.Color := Font.Color; OffsetRect(Rect, -1, -1); DrawText(Canvas.Handle, PChar(Text), Length(Text), Rect, Flags); end; end; end.