Unfolding long ListView labels with in-place tooltips

Category:
Forms and Controls
Type:
Applications
Difficulty:
Advanced
Author:
Anonymous

Version Compatibility: Visual Basic 6

More information:
Everybody knows that many Windows GUI apps are capable of unfolding "long" text if this text is longer than its available "container" and so is "cut" and finished with an ellipsis. A simple example: open MS Outlook, go to Inbox folder and find some message with a LONG Subject text. You'll see this text is cut to the corresponding column width. But if you move the mouse over this text, the so called "in-place tooltip" will appear, unfolding the whole Subject text. The text part of the tooltip will EXACTLY (pixel-to-pixel) cover the source text. It's not easy (and impossible, I guess) to quickly reproduce the same behavour for the VB control "ListView": if we send message LVM_SETEXTENDEDLISTVIEWSTYLE with wParam set to LVS_EX_LABELTIP, this will not solve the problem! If we spend some time to investigate the reason, we will find out that ListView already has the LVS_EX_LABELTIP flag set! And anyway the "label tips" will not appear in neither case. It seems to be an obvious bug in the "MS Windows Common Controls 6.0 (SP6)" OCX, because if we create "SysListView32" window via API CreateWindowEx, we'll see that LVS_EX_LABELTIP flag works perfectly. I failed to find a ready-to-use solution in the Net, and so created my own code to solve the problem. I even didn't try to deal with the LVS_EX_LABELTIP flag; instead, I created the tooltip window "from scratch", attached it to the ListView control, and then positioned it EXACTLY over the source text. And the rezult is a really nice-looking "in-place tooltip"! It's trackable and highly customizable, and of course it is shown only for those listview items and subitems which are really "cut".

Instructions: Click the link below to download the code. Select 'Save' from the IE popup dialog. Once downloaded, open the .zip file from your local drive using WinZip or a comparable program to view the contents.

Download unfolding_long_listview_labels_with_in-place_tooltips.zip