CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2009
    Posts
    2

    Exclamation [Subclassing ListView] How to receive WM_DRAWITEM event ?

    Hello everybody,

    I have a .Net (C#) project for Windows CE 5.

    It's a GUI for which I overload all controls (or nearly) to do what I want and to accelerate the creation of screens in the future...

    In one of the screens, I have a ListView, "CustomListView" that derives from the Windows ListView.
    Here, I would like to display some information in a column such as a progress bar, a flag, etc.
    So I would like to draw the lines myself!

    As we are in the .Net CF, we can't override the OnPaint method, can we?

    What I managed to do is to intercept WM_PAINT Windows message and in my handler, I can draw what I want in the ListView control.
    The problem is that it makes me redraw every time the column headers, manage the selected line (I do but the behavior is strange), the scroll, etc...

    What I would do is to subscribe to the event which is sent each time a line is drawing!
    I understood that it's WM_DRAWITEM, isn't it?
    But by default (it's what I understood once again), we don't receive it because it isn't sent.
    We must put the property LVS_OWNERDRAWFIXED!
    I also add LVS_REPORT ...

    Ok, the event seems to be sent (I see header but no line) but I don't receive the WM_DRAWITEM to call my handler and display my rows

    Usefull links:
    http://msdn.microsoft.com/en-us/library/ms229681.aspx
    http://msdn.microsoft.com/en-us/library/aa453379.aspx

    I did someting wrong?

    Thank you very much!!!

  2. #2
    Join Date
    Jul 2009
    Posts
    2

    Re: [Subclassing ListView] How to receive WM_DRAWITEM event ?

    64 views
    0 replies


  3. #3
    Join Date
    Aug 2005
    Location
    Elkins, NH
    Posts
    7

    Re: [Subclassing ListView] How to receive WM_DRAWITEM event ?

    Take a look at this:

    http://www.codeproject.com/KB/list/B...pListView.aspx

    See the "Points of Interest" section about halfway down the page.
    There are two principal tricks:
    1) Force the LVS_OWNERDRAWFIXED style in your control's OnHandleCreated() (aka OnCreate, aka WM_CREATE).
    2) In your WndProc, handle WM_DRAWITEM | WM_REFLECT (0x202B) *not* simply WM_DRAWITEM (0x002B).

    The rest (drawing the items) is just as you'd expect it to be.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured