问题
I want to draw a rectangle around a ListView item when the ListView is in Icon mode, so I started reading about owner draw which I thought that it will solve my problem.
However, I have also read that owner draw only works in Report mode! Is this still the case under newer versions of Windows (Windows XP and later)?
And if this is still the case, then is there another way to draw a rectangle around a ListView item?
回答1:
Yes, LVS_OWNERDRAWFIXED
style is only meaningful for LVS_REPORT
case. But there's another way - you can process NM_CUSTOMDRAW
notifications that listview sends you. Those are sent for all control modes, and depending on what you want to do you can handle CDDS_ITEMPOSTPAINT
notification, use dwItemSpec
field as item index, send LVM_GETITEMRECT from within your WM_NOTIFY handler, and do whatever you want with it.
来源:https://stackoverflow.com/questions/36442894/does-owner-draw-only-work-in-report-mode-for-listview