unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type TmyHintwindow=class(Thintwindow)
bild:Tbitmap;
constructor create(Aowner:Tcomponent);
override;
destructor Destroy;
override;
procedure paint;
override;
function CalcHintRect(MaxWidth: Integer;
const AHint:
string; AData: Pointer): TRect;
override;
end;
type
TForm1 =
class(TForm)
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
Hintwindow:TmyHintwindow;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor tmyHintwindow.create(Aowner:Tcomponent);
begin
inherited create(Aowner);
bild:=tbitmap.Create;
bild.LoadFromFile('
D:\test.bmp');
end;
destructor tmyhintwindow.destroy;
begin
bild.free;
inherited;
end;
procedure tmyHintwindow.paint;
//Methode neu geschrieben um den Text ein wenig nach rechts zu rücken
var R: TRect;
begin
R := ClientRect;
Inc(R.Left, 52);
Inc(R.Top, 2);
Canvas.Font.Color := Screen.HintFont.Color;
DrawText(Canvas.Handle, PChar(Caption), -1, R, DT_LEFT
or DT_NOPREFIX
or
DT_WORDBREAK
or DrawTextBiDiModeFlagsReadingOnly);
stretchblt(canvas.Handle,2,2,45,45,bild.canvas.handle,0,0,bild.width,bild.height,SRCCOPY);
end;
function TmyHintWindow.CalcHintRect(MaxWidth:Integer;
const AHint:
string;AData:Pointer):TRect;
//Das HintRect wird jetzt etwas größer berechnet
begin
result:=inherited CalcHintRect(MaxWidth,Ahint,AData);
result.Right:=result.Right+50;
if result.Bottom-result.top<50
then result.Bottom:=result.top+50;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
hintwindowclass:=Tmyhintwindow;
//Damit wird immer dein neues Hintwindow verwendet
memo1.showhint:=true;
memo1.Hint:='
Hallo';
end;
end.