CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2004
    Posts
    4

    Question CListView with large number of columns that exceed 32K pixels

    Hi, does anyone know how to overcome the 32K pixel width limit of the CHeaderCtrl in a CListView?

    When the total width of the list control exceeds 32767 pixels, the main list control is painted correctly but the header control stops at the 32K limit. This has nothing to do with owner-draw headers but the actual header control boundaries are clipped.

    Would be gratefull if anyone knows of a fix or any other similar problems with window sizes exceeding 32K.

  2. #2
    Join Date
    Feb 2002
    Posts
    5,757
    Check out CodeProject code section to see if there is a custom header control. Search Google.

    Kuphryn

  3. #3
    Join Date
    Mar 2004
    Posts
    4
    Thanks but i've already been to CodeProject and there is nothing on width problems. The samples there with custom list controls and headers all suffer from the same problem, just that no one every tests them with widths of greater than 32K pixels!

  4. #4
    Join Date
    May 2000
    Location
    Scotland, Livingston.
    Posts
    728
    Did you find a solution to your peoblem?
    I have the same problem.
    Dave Mclelland.

  5. #5
    Join Date
    Mar 2004
    Posts
    4
    Sort off, I made a separate CHeaderCtrl and placed it on top of the CListView making sure that the false header's position always lie within the client area of the CListView. I then processed the messages for the false header and then adjusted the real header accordingly. The only other thing to handle yourself is scrolling. When the view scrolls horizontally, i find which real column is in view and adjust the column of the false header accordingly. All in all it works very well and the user has no idea that it not the real header. The only slight fault that I know of is that when the very last column (rightmost) is resized by dragging the divider, the view's horizontal scroll bar does not re-scale until you let go of the divider! This is a very minor "difference" that I can live it. Other than that it works perfectly. Would you like the code?

  6. #6
    Join Date
    May 2000
    Location
    Scotland, Livingston.
    Posts
    728
    Yes please.
    Dave Mclelland.

  7. #7
    Join Date
    Mar 2004
    Posts
    4
    Hi, Here is a new class called CListViewEx that I wrote. It can be used just like the standard CListView with a few extra calls. The 2 source files are CListViewEx.cpp and .h respectively. The sample calling file is AlarmWnd.cpp. I have stripped all "Company" information from these files and removed all unnecessary code not relating to the use of the CListViewEx and hence it will not compile directly. It is very simple. Look at the OnCreate override for CAlarmWnd, it simply calls the default OnCreate function and creates an image list for the list control. The image list contains bitmaps for the sort up and down arrows placed on the header. It can also include images for the rows of the list control. Addtional functions used are SetFont() which sets both the header and list fonts. The function SetSortImageIndexes() is called to set the SortUp and SortDown bitmap indexes within the imagelist. There is also a function called OnColumnSort() which is called when the user clicks on a header column. This merely implements the standard CListView callback but is neatly coded to provide a override function. The final bit is the OnEraseBkgnd() function which is used to draw the actual background colour of the main list view. Strangely the real background colour is always used to draw any transparent bits of the header so if you have non-rectangular bitmap for the sort up/down bitmap, you should call ListCtrl.SetBkColor(GetSysColor(COLOR_BTNFACE)) to make it consistent.
    Attached Files Attached Files

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