简体   繁体   中英

C++ - ListView Custom Drawn on Windows XP

I have ListView which items are completely drawn using my code. Of course I use data provided by NMLVCUSTOMDRAW primarily RECTs. There are two rects p->nmcd.rc and p->rcText, first one carries valid information and the other one is always 0. This issue is that nmcd.rc does not contain valid rect on Windows XP I get 0,1,0,2 or something like that.

As that did not work I tried using ListView_GetItemIndexRect which fails on Win XP, while it works on Win 7/10.

Looking at the ListView_GetItemIndexRect's msdn page I can see that apparently it works only on Vista+. While at the same time some other ListView functions that are listed as Vista+ work fine on Windows XP.

Windows XP is rare among my program's users, but still I'd like it to function perfectly. Drawing complete list view on my own would fix the problem for sure, but that is a dead end.

Check out the first comment on this page:

https://msdn.microsoft.com/en-us/library/windows/desktop/bb774778%28v=vs.85%29.aspx

Handling subitem pre-paint messages on Windows XP (perhaps all pre-Vista systems?) the handler receives incorrect top and bottom values in NMLVCUSTOMDRAW::nmcd.rc, sometimes they are zero, sometimes are not updated since previous handler call (so basically the idea is that they are left uninitialized by comctl32 caller). In order to get correct subitem position the handler has to explicitly obtain rectangle using a separate message/call:

RECT Position; ListView.GetSubItemRect((INT) pHeader->nmcd.dwItemSpec, pHeader->iSubItem, LVIR_BOUNDS, &Position);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM