2024年4月11日发(作者:)

THintWindow高级用法

THintWindow 的 ActivateHint 和 ActivateHintData 怎么用?

procedure ActivateHintData(Rect: TRect; const AHint: string; AData:

Pointer); virtual;

AData 指的是什么?

能否给个具体例子?

多谢!

var

h : THintWindow;

r : TRect;

begin

with r do

begin

// set the position and size

// of the hint window

left := 10;

top := 50;

right := 200;

bottom := 100;

end;

h := ( Self );

with h do

begin

// set the background color

Color := clRed;

ActivateHint( r, 'hi there!' );

// perform your tasks here

// before closing the hint window

MessageBox( 0,'Press any key to close the ' + 'hint window',

'THintWindow', MB_OK );

ReleaseHandle;

Free;

end;

end;

---------------------------------------------------------------------

-----------

来自:笑傲江湖 时间:01-1-20 8:57:10 ID:443232

AData 指的是什么?

能否给个具体例子?

----AData是一个(关联的)指针,

目前来说, ActivateHintData和ActivateHint等效, 因为AData参数被忽

略.

在THintWindow类中, ActivateHintData被定义成Virtual的,

后代类可以重载这个方法, 把AHint 和AData所关联的信息

重新组合成自己需要的HINT方式.

以下是THintWindow的源码部分:

procedure teHint(Rect: TRect; const AHint: string);

begin

FActivating := True;

try

Caption := AHint;

Inc(, 4);

UpdateBoundsRect(Rect);

if + Height > pHeight then

:= pHeight - Height;

if + Width > pWidth then

:= pWidth - Width;

if < pLeft then :=

pLeft;

if < pTop then :=

pTop;

SetWindowPos(Handle, HWND_TOPMOST, , , Width,

Height,

SWP_SHOWWINDOW or SWP_NOACTIVATE);

Invalidate;

finally

FActivating := False;

end;

end;

procedure teHintData(Rect: TRect; const AHint:

string; AData: Pointer);

begin

ActivateHint(Rect, AHint);//AData参数被忽略, 你可以传个nil, 或任

意一个指针

end;

dePause:=99999999; //防止闪烁

getcursorpos(cursorpos);

:='XXX';

tehint(cursorpos);