开发者

Problem with a custom drawn list view

开发者 https://www.devze.com 2023-01-06 21:40 出处:网络
I created a list view class that uses Custom Draw for its rendering. It all works well except that it doesn\'t render anything. I subclassed its parent window to catch the NM_CUSTOMDRAW notification a

I created a list view class that uses Custom Draw for its rendering. It all works well except that it doesn't render anything. I subclassed its parent window to catch the NM_CUSTOMDRAW notification as a WM_NOTIFY message. However, it appears that WM_NOTIFY is only triggered a few times during creation of the control and never again after that. So the NM_CUSTOMDRAW code is never executed.

I ch开发者_如何学Pythonecked with Winspector Spy so see if the control is laid out correctly in the parent window and that seems to be fine.

Does anyone have a clue about what I may be doing wrong?

The code can be found online:

  • WindowsListView.h
  • WindowsListView.cpp


Why are you drawing text in CDDS_ITEMPOSTPAINT? You should probably draw your text in CDDS_ITEMPREPAINT and return CDRF_SKIPDEFAULT. Also, you should not use the rect in NMCUSTOMDRAW, call ListView_GetItemRect to get the rect you are really after (LVIR_LABEL for text etc)


It doesn't look like you're using the LVS_OWNERDRAWFIXED style, which could explain why you don't get owner-draw messages.


I needed to call ShowWindow(mHandle, SW_SHOW); after creating the list view.

Doh!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号