开发者

Owner-draw ListBox using Compact Framework

I want to subclass the ListBox control and set the LBS_OWNERDRAWVARIABLE‎ style. Subclassing is no problem and I can get messages through my own WndProc. (Actually I subclass the ListBox's parent in this case, as it is what is supposed to receive the WM_MEASUREITEM and WM_DRAWITEM messages). The problem is that I never get WM_MEASUREITEM or WM_DRAWITEM messages and the control continues to paint itself.

Both styles should be supported in WM5.0 and up:

  WinCE3.0 supports neither: http://msdn.microsoft.com/en-us/library/ms959988.aspx

  WinCE5.0 supports both: http://msdn.microsoft.com/en-us/library/aa453299.aspx

Even LBS_OWNERDRAWFIXED would be a start, but I can't get either to work.

My best guess is that the LBS_OWNERDRAWx style needs to be set at CreateWindowEx() time, as SetWindowLong() doesn't seem to change it. If that's the case, CF doesn't expose any methods that let me override window creation, and a开发者_运维百科lso doesn't expose anything like CreateParams (in full framework) or PreCreateWindow() that allows modifying the window-style before creation. (They're all there in the Control class but they're internal, so not accessible).

Has anyone managed to successfully do owner-drawing (even FIXED) using the actual Windows ListBox control on CF? Alternately, has anyone figured out a way to override the window-styles passed to CreateWindowEx() in a Control-based control? If so, please share your secrets :-)

Note: I do not want to create a list control from scratch; I can do that and there are various good examples of that out there, but that's not what this question is about.

CF2.0; WM6.1.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜