ListBox2 / Owner drawn ListView : LargeIcon's

Last post 06-03-2008 7:19 by zeno. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 04-28-2008 6:36

    • zeno
    • Top 25 Contributor
    • Joined on 09-10-2007
    • Posts 13

    ListBox2 / Owner drawn ListView : LargeIcon's

    Hi There,

    We have succesfully been using the OpenNETCF's ListBox2 control in a lot of our projects: We love this control to draw custom lists.

    No we have a new project in which we have to present the user with a custom list much more in the form of the LargeIcon's view of the ListView control.

     
    We are wondering if the ListBox2 can somehow be changed to display items next to eachother (Large Icons). Or maybe there is already a owner drawn ListView-control? (or an easy way to change it's item_paint routines).

     

    Any help will be greatly appreciated!

     

    Cheers,

    Zeno.
     

     

  • 04-28-2008 8:20 In reply to

    • ctacke
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-27-2007
    • Indiana
    • Posts 1,868

    Re: ListBox2 / Owner drawn ListView : LargeIcon's

    Singe ListBox2 derives from the native ListBox, it's going to be saddled with the behavior of a full "line" for an item without a *lot* of rework (i.e. detecting where a click happens and turning that into a virtual "item".  I certainly wouldn't recommend it.  You're likely going to want to go with a ListView and owner-draw it. 

  • 04-28-2008 8:26 In reply to

    • zeno
    • Top 25 Contributor
    • Joined on 09-10-2007
    • Posts 13

    Re: ListBox2 / Owner drawn ListView : LargeIcon's

     

    Thanks for the quick reply CTacke, I figured doing an owner-drawn ListView would be the smartest choice. But I cannot seem to find any starting place on the internet to begin with doing this.

    Do you perhaps have some pointers as to where to begin?

     

    Thanks again! 


     

  • 04-28-2008 8:44 In reply to

    • ctacke
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-27-2007
    • Indiana
    • Posts 1,868

    Re: ListBox2 / Owner drawn ListView : LargeIcon's

    This is a reasonable start:

    http://msdn2.microsoft.com/en-us/library/aa446513.aspx 

  • 04-28-2008 8:54 In reply to

    • zeno
    • Top 25 Contributor
    • Joined on 09-10-2007
    • Posts 13

    Re: ListBox2 / Owner drawn ListView : LargeIcon's

    Thanks! That looks like a good starting point indeed.

     

    I'll have a look into that and report my progress / results back her. I did start playing around with custom image drawing of items and putting them in an image list. But got stuck there with not being able to (for instance) remove the text of items.

    This article will probably speed things up.

     


     

  • 04-28-2008 10:14 In reply to

    • zeno
    • Top 25 Contributor
    • Joined on 09-10-2007
    • Posts 13

    Re: ListBox2 / Owner drawn ListView : LargeIcon's

    The custom listview in the article is also really designed for line-by-line use. (one item is a full line, instead of multiple items per line).

     

    I would think it is possible to somehow send the LVS_OWNERDRAWFIXED property to the native control, and catch the DRAWITEM window messages. This way the multi-item logic will be done by the native control, and I should write the custom painting routines for the items.
     

  • 05-14-2008 7:02 In reply to

    • zeno
    • Top 25 Contributor
    • Joined on 09-10-2007
    • Posts 13

    Re: ListBox2 / Owner drawn ListView : LargeIcon's

     Allright, I managed to send the LVS_OWNERDRAWFIXED (= 0x0400) to the Listview control:

         int lStyle = (int)NativeMethods.GetWindowLong(this.Handle, -16);
         string bp = "lstylehier";
         lStyle |= (0x0400 | 0x0001);
         int iRet = NativeMethods.SetWindowLong(this.Handle, -16, lStyle);

     

    When I do this, I see the following window messages come by:

    125 WM_STYLECHANGED

    641 WM_IME_SETCONTEXT

    7 WM_SETFOCUS

    15 WM_PAINT

    71 WM_WINDOWPOSCHANGED

    3 WM_MOVE

    5 WM_SIZE

    20 WM_ERASEBKGND

    78 WM_NOTIFY

     

    I also expect the  43 WM_DRAWITEM (0x002B) message to come by.. but I never get it. The listview does not show it's items tough, so I suspect that the style change was indeed succefull (as also indecated by the first WM ).

     

     

    Any ideas? 

  • 05-14-2008 7:18 In reply to

    • zeno
    • Top 25 Contributor
    • Joined on 09-10-2007
    • Posts 13

    Re: ListBox2 / Owner drawn ListView : LargeIcon's

     When I set the view-property of the listview to LargeIcon ( listView.View = View.LargeIcon; ) I also get thes three window messages, which I can't find on the net anywhere..:

    4100 ( 0x1004 )
    4211 ( 0x1073 )
    4149 ( 0x1035 )
    4117 ( 0x1015 )

  • 06-03-2008 7:19 In reply to

    • zeno
    • Top 25 Contributor
    • Joined on 09-10-2007
    • Posts 13

    Re: ListBox2 / Owner drawn ListView : LargeIcon's

    Can't seem to get it to work..

    Anyone has some pointers on the window messages? / How to get this working?

    I read somewhere that it is not going to work unless you host the native control yourself (can't find more detail on that).

     

     

    For now I am resorting to a panel filled with owner-drawn buttons. Kind of works, but it's also pretty slow when scrolling. (+/- 60 items in the panel)

     

Page 1 of 1 (9 items)