A customer had a Win32 common controls ListView in single-click mode. This has a side effect of enabling hover effects: When the mouse hovers over an item, the cursor changes to a hand, and the item gets highlighted in the hot-track color. How can they suppress these hover effects while still having single-click activation?
When the user hovers over an item, the ListView sends a LVN_ notification, and you can suppress all hot-tracking effects by returning 1.
// WndProc
case WM_NOTIFY:
{
auto nm = (NMLISTVIEW*)lParam;
if (nm->hdr.code == LVN_HOTTRACK)
{
return 1;
}
}
break;
If you are doing this from a dialog box, you need to set the DWLP_ to the desired return value, which is 1 in this case, and then return TRUE to say “I handled the message; use the value I put into DWLP_.”
// DlgProc
case WM_NOTIFY:
{
auto nm = (NMLISTVIEW*)lParam;
if (nm->hdr.code == LVN_HOTTRACK)
{
SetWindowLongPtr(hDlg, DWLP_MSGRESULT, 1);
return TRUE;
}
}
break;
0 comments
Be the first to start the discussion.