unit unit1;
interface
uses
windows, messages, sysutils, variants, classes, graphics, controls, forms,
dialogs, stdctrls;
type
tform1 = class(tform)
button1: tbutton;
label1: tlabel;
procedure button1click(sender: tobject);
private
{ private declarations }
procedure wmwindowposchanging(var msg: tmessage); message wm_windowposchanging;
public
{ public declarations }
end;
var
form1: tform1;
implementation
uses unit2;
{$r *.dfm}
type
thintwindowex = class(thintwindow)
public
procedure activatehint(rect: trect; const ahint: string); override;
end;
thintwindowaccess = class(tcustomcontrol)
private
factivating: boolean;
flastactive: cardinal;
end;
procedure thintwindowex.activatehint(rect: trect; const ahint: string);
type
tanimationstyle = (atslideneg, atslidepos, atblend);
const
animationstyle: array[tanimationstyle] of integer = (aw_ver_negative,
aw_ver_positive, aw_blend);
var
animate: bool;
style: tanimationstyle;
begin
thintwindowaccess(self).factivating := true;
try
caption := ahint;
inc(rect.bottom, 4);
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_noactivate);
if (gettickcount - thintwindowaccess(self).flastactive > 250) and (length(ahint) < 100) and
assigned(animatewindowproc) then
begin
systemparametersinfo(spi_gettooltipanimation, 0, @animate, 0);
if animate then
begin
systemparametersinfo(spi_gettooltipfade, 0, @animate, 0);
if animate then
style := atblend
else
if mouse.cursorpos.y > rect.top then
style := atslideneg
else
style := atslidepos;
animatewindowproc(handle, 100, animationstyle[style] or aw_slide);
end;
end;
//parentwindow := application.handle;
showwindow(handle, sw_shownoactivate);
invalidate;
finally
thintwindowaccess(self).flastactive := gettickcount;
thintwindowaccess(self).factivating := false;
end;
end;
procedure tform1.button1click(sender: tobject);
begin
hintwindowclass := thintwindowex;
application.showhint := false;
application.showhint := true;
form2 := tform2.create(self);
form2.show;
end;
procedure tform1.wmwindowposchanging(var msg: tmessage);
begin
inherited;
end;
end.