unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ShellAPI;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TGraphicHintWindow = class(THintWindow)
constructor Create(AOwner: TComponent); override;
private
FActivating: Boolean;
public
procedure ActivateHint(Rect: TRect; const AHint: string); override;
protected
procedure Paint; override;
published
property Caption;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor TGraphicHintWindow.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
// Hint ÀÇ font
with Canvas.Font do
begin
Name := '±¼¸²Ã¼';
Size := 9;
Style := Style + [fsBold];
Color := clBlack;
end;
end;
procedure TGraphicHintWindow.Paint;
var
R: TRect;
bmp: TBitmap;
IcoHandle: THandle;
MyIcon: TIcon;
begin
R := ClientRect;
Inc(R.Left, 2);
Inc(R.Top, 2);
// ¾Æ·¡ bmp ´Â ÀÓÀÇÀÇ bitmapÀ» »ç¿ëÇØµµ µÇ³ª ¿¹Á¦¸¦ À§ÇØ Delphi À̹ÌÁö¸¦ ±×´ë·Î »ç¿ëÇßÀ½
IcoHandle := ExtractIcon(Application.Handle, PChar(Application.ExeName), 0);
MyIcon := TIcon.Create;
MyIcon.Handle := IcoHandle;
bmp := TBitmap.Create;
with bmp do
begin
width := MyIcon.Width;
Height := MyIcon.Height;
Canvas.Brush.Color := clOlive;
Canvas.Pen.Style := psClear;
Canvas.Rectangle(0, 0, Width+1, Height+1);
Canvas.Draw(0, 0, MyIcon);
end;
with Canvas do
begin
Brush.Style := bsSolid;
Brush.Color := clsilver;
Pen.Color := clgray;
Rectangle(0, 0, 18, R.Bottom + 1);
Draw(2, (R.Bottom div 2)-(bmp.Height div 2), bmp);
end;
bmp.Free;
Color := GetSysColor(COLOR_INFOBK); // Hint ÀÇ BackGround Color
Canvas.Brush.Style := bsClear;
Canvas.TextOut(35, (R.Bottom div 2)-(Canvas.Textheight(Caption) div 2), Caption); // TextÀÇ Ç¥½Ã À§Ä¡ ÁöÁ¤
end;
procedure TGraphicHintWindow.ActivateHint(Rect: TRect; const AHint: string);
begin
FActivating := True;
try
Caption := AHint;
Inc(Rect.Bottom, 24); // Hint ÀÇ ³ôÀÌ(Height)
Rect.Right := Rect.Right + 40; // HintÀÇ Æø(Width)
UpdateBoundsRect(Rect);
if Rect.Top + Height > Screen.DesktopHeight then
Rect.Top := Screen.DesktopHeight - Height;
if Rect.Left + Width > Screen.DesktopWidth then
Rect.Left := Screen.DesktopWidth - Width;
if Rect.Left < Screen.DesktopLeft then Rect.Left := Screen.DesktopLeft;
if Rect.Bottom < Screen.DesktopTop then Rect.Bottom := Screen.DesktopTop;
SetWindowPos(Handle, HWND_TOPMOST, Rect.Left, Rect.Top, Width, Height,
SWP_SHOWWINDOW or SWP_NOACTIVATE);
Invalidate;
finally
FActivating := False;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
HintWindowClass := TGraphicHintWindow;
Application.ShowHint := False;
Application.ShowHint := True;
Button1.Hint := '±è¿µ´ëÀÇ È¨ÆäÀÌÁö -> http://www.howto.pe.kr';
Button1.ShowHint := True;
end;
end. |
|