unit ShadowEffectDemo;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TfrmMain = class(TForm)
txtText: TEdit;
Label1: TLabel;
btnShadow: TButton;
btnExit: TButton;
procedure btnExitClick(Sender: TObject);
procedure btnShadowClick(Sender: TObject);
private
{ Private declarations }
procedure FirstMethod;
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
{$R *.dfm}
procedure TfrmMain.btnExitClick(Sender: TObject);
begin
Close;
end;
procedure TfrmMain.btnShadowClick(Sender: TObject);
begin
FirstMethod;
end;
procedure TfrmMain.FirstMethod;
var
lf: LOGFONT; // Windows native font structure
text: string;
begin
Canvas.Brush.Style := bsClear; // set the brush style to transparent
FillChar(lf, SizeOf(lf), Byte(0)) ;
lf.lfHeight := 20;
lf.lfFaceName := 'Arial';
Canvas.Font.Handle := CreateFontIndirect(lf) ;
Canvas.Font.Color := clBlack;
text := txtText.Text;
Canvas.TextOut(20, 100, text) ; // shadow in black
Canvas.Font.Color := clGray;
Canvas.TextOut(19, 99, text) ; // text in gray 1pxl left and up
end;
end.
|