How to prevent a TListView from displaying tool tips for long items #158
When a listview displays an item or sub-item that is too wide for its column the text gets truncated to fit. The list view control helpfully displays a hint containing the full text when you hover the mouse over the item.
Usually that is welcome behaviour. But what if you don't want it to do that? How do you stop it?
The list view control displays the info tip if it has the LVS_EX_INFOTIP extended style flag set. To inhibit the tips we need to remove the flag. Here is a little routine to do the job:
uses CommCtrl; procedure InhibitLVInfoTips(const LV: TListView); begin ListView_SetExtendedListViewStyle( LV.Handle, ListView_GetExtendedListViewStyle(LV.Handle) and not LVS_EX_INFOTIP ); end;
Note that this method has no effect when the list view style is vsIcon: the tool tip is still displayed.
To use the routine just call it from somewhere convenient, say a form's OnCreate event handler, as pass it a reference to the list view control where you want to disabled the hints, e.g.:
procedure TForm1.FormCreate(Sender: TObject); begin InhibitLVInfoTips(ListView1); end;