Reputation: 6272
I've got a listview in report view that I'm trying to display tooltips for, different per item.
But I can't get any tooltip to be displayed at all...
Here's what I figured out so far:
case LVN_GETINFOTIP:
{
LPNMLVGETINFOTIP GetInfoTip = (LPNMLVGETINFOTIP) lParam;
GetInfoTip->pszText = L"TESTING";
// What do I do now? How do I display the tooltip?
return 0;
}
After I have received the LVN_GETINFOTIP
message, how do I display the tooltip?
Upvotes: 2
Views: 2518
Reputation: 11
The Windows documentation suggests that LVN_GETINFOTIP is not sent by report view listview controls. In practice I found this to be the case (2024).
So in these circumstances how to display the tooltip?
I can see why it's necessary to find some alternative to an ordinary tooltip window when using a listview control. The problem with a large control like a listview is that although a TTN_NEEDTEXT notification message (asking for the display text to be specified) will be sent when the cursor first enters the control, a second TTN_NEEDTEXT will not be sent if the cursor then moves within the control onto a different item. This is because the cursor is still in the same control.
One workaround for this is to set the listview style to LVS_EX_TRACKSELECT and then monitor the LVN_HOTTRACK messages sent to the listview's parent. When monitoring this message, if iItem in NMLISTVIEW is -1 then the cursor is in the listview but is not over an item so no action should be taken. But otherwise you can send TTM_POPUP to the tooltip window.
This causes the tooltip to appear at the cursor and before doing so it will send TTN_NEEDTEXT to the window which was specified when the tooltip was associated with the listview using TTM_ADDTOOL.
To avoid sending TTM_POPUP each time the cursor moves in the listview control, only send it if hItem (and iSubItem if required to be tested) is different from the last time LVN_HOTTRACK was received.
Upvotes: 0
Reputation: 11
LPNMLVGETINFOTIP pGetInfoTip = reinterpret_cast<LPNMLVGETINFOTIP>(pNMHDR);
in report mode,at least, you will only get the message when mouse is over the 0th column
Upvotes: 0
Reputation: 3226
The problem is that you are replacing the pointer pszText
. You need to modify the contents of the memory buffer instead. For example using StringCchPrintf
.
Upvotes: 3