我的tlistView控件已启用ShowHints
并处理OnInfoTip
事件。弹出式Infotip框中的消息设置在OnInfoTip
处理程序中。但是,弹出式Infotip框的位置是相对于鼠标悬停在列表中的项目时的位置。似乎没有一种自定义位置的方法。
是否可以设置提示弹出窗口的位置,例如在tlistview的特定区域,甚至在tlistview控件边界外的形式的其他位置?理想情况下,我想以这种方式显示提示弹出窗口,以最大程度地减少(或消除)模糊TlistView中的任何其他物品。
首先,您必须揭露tlistView的cmhintshow如下:
type
TListView = class(Vcl.ComCtrls.TListView)
private
FPos: TPoint;
protected
procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
published
property MyPos: TPoint read FPos write FPos;
end;
TfrmMain = class(TForm)
...
ListView1: TListView;
然后,在OnInfotip事件中,您设置了所需的位置。在我的示例中,我得到了滚动箱(Sbxfilter-位于tlistview下方)的高级角落的坐标,然后将坐标传递到tlistview属性mypos。
procedure TfrmMain.ListView1InfoTip(Sender: TObject; Item: TListItem; var InfoTip: string);
var
p: TPoint;
begin
InfoTip := 'Test';
p := sbxFilter.ClientToScreen(point(0, 0));
ListView1.MyPos := p;
end;
{ TListView }
procedure TListView.CMHintShow(var Message: TCMHintShow);
begin
inherited;
Message.HintInfo.HintPos := FPos;
end;
可以显示提示,您在OnInfoTip()
事件中定义了例如StatusBar
的StatusPanel
(在表单的底部)。
例如:
procedure TForm1.ListView1InfoTip(Sender: TObject; Item: TListItem;
var InfoTip: string);
begin
InfoTip := '';
StatusBar1.Panels[0].Text := 'ListView Infotip, Item '+IntToStr(Item.Index);
end;