THintWindow 这么用?(100分)

  • 主题发起人 主题发起人 netkk
  • 开始时间 开始时间
N

netkk

Unregistered / Unconfirmed
GUEST, unregistred user!
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 := THintWindow.Create( 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;
 
AData 指的是什么?
能否给个具体例子?
----AData是一个(关联的)指针,
目前来说, ActivateHintData和ActivateHint等效, 因为AData参数被忽略.

在THintWindow类中, ActivateHintData被定义成Virtual的,
后代类可以重载这个方法, 把AHint 和AData所关联的信息
重新组合成自己需要的HINT方式.

以下是THintWindow的源码部分:


procedure THintWindow.ActivateHint(Rect: TRect; const AHint: string);
begin
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_SHOWWINDOW or SWP_NOACTIVATE);
Invalidate;
finally
FActivating := False;
end;
end;

procedure THintWindow.ActivateHintData(Rect: TRect; const AHint: string; AData: Pointer);
begin
ActivateHint(Rect, AHint);//AData参数被忽略, 你可以传个nil, 或任意一个指针
end;
 
小弟想试试,不知那个控件怎么找到??怎么装到delphi上???谢谢!
 
to cgh0717:
THintWindow是VCL原生类.
不是第三方控件.
 
Application.HintHidePause:=99999999; //防止闪烁
getcursorpos(cursorpos);
LvwGrp.Hint:='XXX';
application.activatehint(cursorpos);
 
多人接受答案了。
 
后退
顶部