Microsoft KB Archive/131788

From BetaArchive Wiki

OdListVw.exe Highlights Entire Row in a ListView Control

Q131788



The information in this article applies to:


  • Microsoft Win32 Application Programming Interface (API), used with:
    • Microsoft Windows 95
    • Microsoft Windows NT Server version 3.51
    • Microsoft Windows NT Workstation version 3.51
    • the operating system: Microsoft Windows 2000
    • Microsoft Win32s version 1.3





SUMMARY

One of the limitations of the ListView common control is that when the control is in report view, the control only highlights the first column when a row is selected. To work around this limitation, you can create the ListView as an owner draw control (using the LVS_OWNERDRAWFIXED style) and perform all the painting yourself.

The ODLISTVW sample demonstrates how to create an owner draw ListView control that highlights an entire row.



MORE INFORMATION

The following file is available for download from the Microsoft Download Center:


Odlist.exe

For additional information about how to download Microsoft Support files, click the article number below to view the article in the Microsoft Knowledge Base:

Q119591 How to Obtain Microsoft Support Files from Online Services

Microsoft used the most current virus detection software available on the date of posting to scan this file for viruses. Once posted, the file is housed on secure servers that prevent any unauthorized changes to the file.

One of the supported styles for the ListView control is LVS_OWNERDRAWFIXED, which allows the program to perform all the drawing of items in the ListView control. Whenever the ListView control needs to have a portion of the control repainted, it calculates which items are in that area and sends a WM_DRAWITEM message to its parent for each item. If any part of an item needs to be redrawn, the ListView sends the WM_DRAWITEM with the update rectangle set to the entire item.

The ListView control handles owner drawn items differently from other owner drawn controls. Previous owner drawn controls use the DRAWITEMSTRUCT's itemAction field to let the parent know if it needs to draw the item, change the selected state, or change the focus state. The ListView control always sends the WM_DRAWITEM message with the itemAction set to ODA_DRAWENTIRE. The parent needs to check the itemState to see if the focus or selection needs to be updated.

The LVS_OWNERDRAWFIXED style is only compatible with the LVS_REPORT style. You cannot have an owner drawn ListView with the LVS_ICON, LVS_SMALLICON or LVS_LIST style.

Additional query words: CListCtrl CListView list control kbui kbfile

Keywords : kbfile kbsample kbCtrl kbOSWinNT351 kbOSWin2000 kbSDKWin32 kbGrpDSUser kbOSWin95
Issue type : kbinfo
Technology : kbAudDeveloper kbWin32sSearch kbWin32API


Last Reviewed: December 16, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.