IE4 Extended Styles in a List Control


Application Security Testing: An Integral Part of DevOps

If you Ever wanted to do a full row select, be able to drag a whole column to another position, draw a grid and do some other interesting things to your CListCtrl derived class. Well now you can by setting the extended styles associated with the CListCtrl. This article will give the various flags, their uses, the applicable COMCTL32.DLL version and some code snippets used in a CListView derived class, which as you know has a CListCtrl item buried in it.

Depending on which version of the common controls DLL you have, there are extended styles which can be invoked to support a wide and interesting range of functions. You can download a free restributable version of the latest common controls DLL from Microsoft, complete with its own installer. (See home page for details).

Here's a description of the various extended styles available.

LVS_EX_CHECKBOXES Version 4.70. Enables check boxes for items in a list view control. Effectively, when this style is set, the control will create and set a state image list using DrawFrameControl. Check boxes are visible and functional with all list view modes. The state of the check box for a given item is obtained using the ListView_GetCheckState macro.

LVS_EX_FLATSB Version 4.71. Enables flat scroll bars in the list view. If you need more control over the appearance of the list view's scroll bars, you should manipulate the list view's scroll bars directly using the Flat Scroll Bar APIs.

LVS_EX_FULLROWSELECT Version 4.70. When an item is selected, the item and all its subitems are highlighted. This style is available only in conjunction with the LVS_REPORT style.

LVS_EX_GRIDLINES Version 4.70. Displays gridlines around items and subitems.This style is available only in conjunction with the LVS_REPORT style.

LVS_EX_HEADERDRAGDROP Version 4.70. Enables drag-and-drop reordering of columns in a list view control. This style is only available to list view controls that use the LVS_REPORT style.

LVS_EX_INFOTIP Version 4.71. The list view control sends an LVN_GETINFOTIP notification message to the parent window before displaying an item's tooltip.This style is only available to list view controls that use the LVS_ICONstyle.

LVS_EX_MULTIWORKAREAS Version 4.71. If the list view control has the LVS_AUTOARRANGE style, the control will not autoarrange its icons until one or more work areas are defined (see LVM_SETWORKAREAS). To be effective, this style must be set before any work areas are defined and any items have been added to the control.

LVS_EX_ONECLICKACTIVATE Version 4.70. The list view control sends an LVN_ITEMACTIVATE notification message to the parent window when the user clicks an item. This style also enables hot tracking in the list view control. Hot tracking means that when the cursor moves over an item, it is highlighted but not selected. LVS_EX_REGIONAL Version 4.71. The list view will create a region that includes only the item icons and text and set its window region to that using SetWindowRgn. This will exclude any area that is not part of an item from the window region. This style is only available to list view controls that use the LVS_ICON style.

LVS_EX_SUBITEMIMAGES Version 4.70. Allows images to be displayed for subitems. This style is available only in conjunction with the LVS_REPORT style.

LVS_EX_TRACKSELECT Version 4.70. Enables hover selection in a list view control. Hover selection (also called track selection) means that an item is automatically selected when the cursor remains over the item for a certain period of time. The delay can be changed from the default system setting with the LVM_SETHOVERTIME message. This style applies to all styles of list view control.

LVS_EX_TWOCLICKACTIVATE Version 4.70. The list view control sends an LVN_ITEMACTIVATE notification message to the parent window when the user double-clicks an item. This style also enables hot tracking in the list view control. Hot tracking means that when the cursor moves over an item, it is highlighted but not selected.

LVS_EX_UNDERLINECOLD Version 4.71. Causes nonhot items to be displayed with underlined text. This style is ignored if LVS_EX_ONECLICKACTIVATE is not set.

LVS_EX_UNDERLINEHOT Version 4.71. Causes hot items to be displayed with underlined text. This style is ignored if LVS_EX_ONECLICKACTIVATE or LVS_EX_TWOCLICKACTIVATE is not set.

After the creation of your view, derived from CListView, you may set the extended style of the list control using the following code. As there is currently no CListCtrl::SetExtendedStyle() you have to do a little bit of work until this method has been added.

There are two macros which support extended styles and are implemented as such:

void CDerivedListView::OnInitialUpdate()
  //The macro ListView_GetExtendedListViewStyle takes a reference to the
  // CListCtrl and returns the current extended style (a DWORD)

  DWORD dwStyle = ListView_GetExtendedListViewStyle(GetListCtrl());

 //Add the full row select and grid line style to the existing extended styles

  //The macro ListView_SetExtendedListViewStyle takes a reference to the
  // CListCtrl and the extended style you would like to implement

  ListView_SetExtendedListViewStyle( GetListCtrl(),dwStyle);

Or you could send messages to the control like this:

void CDerivedListView::OnInitialUpdate()
  DWORD dwStyle;
  dwStyle = GetListCtrl().SendMessage(LVM_GETEXTENDEDLISTVIEWSTYLE, 0 ,0);
  GetListCtrl().SendMessage( LVM_SETEXTENDEDLISTVIEWSTYLE, 0,dwStyle );

But a more conventional approach would probably be:

void CDerivedListView::OnInitialUpdate()

void CDerivedListView::AddExStyle(DWORD dwNewStyle)
    CListCtrl& m_listctrl = GetListCtrl();
    DWORD dwStyle = m_listctrl.SendMessage(LVM_GETEXTENDEDLISTVIEWSTYLE,0,0);
    dwStyle |= dwNewStyle;
    m_listctrl.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dwStyle);


  • List control grid lines.

    Posted by Legacy on 03/04/2003 12:00am

    Originally posted by: Jag

    I added 3 colums to list control. The control have LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT style. I draged the vertical grid line of first column header to leftmost position so that the first column will not be shown. then i moved that to original position the vertical grid line disappears , but the column header is shown. How can i show the vertical gridlines.

    • list box

      Posted by abhilashmkm on 07/06/2006 08:30am

      i have to draw grid lines in list box

  • How to print

    Posted by Legacy on 06/01/2002 12:00am

    Originally posted by: seshu

    Dear sir
    i am trying to print the contents of the listbox using right clik or with menu option . But iam failed to do this
    give me an idea.

  • Where do I find the constants (what .H file) to #include?

    Posted by Legacy on 04/26/2001 12:00am

    Originally posted by: David

    What is the header file that includes all of these constants (so that I don't have to dig them up and type them into my own header file)?

    Thanks a bunch.

  • About the Dll Version

    Posted by Legacy on 04/01/2000 12:00am

    Originally posted by: Bird


    I have a ploblem want your help, I had user VC++6.0 to develop an application ,in this application ,I use the CListCtrl and the new style--GRIDLIME, it run good in my computer, but run wrong in the other computer, in my comperter, the version of comctrl.dll is 4.72.3611.1900,the other computer , the version is 4.72.3007.0 .


    Thanks for your help.


  • Adding buttons into the scroll bar of a List Control

    Posted by Legacy on 12/08/1999 12:00am

    Originally posted by: Jean-Claude Parisio

    How can I add push buttons into the vertical scroll bar of an ownerdrawn list control (like the next/previous page buttons in a Word document) ?

  • Bug with ListView FULLROWSELECT?

    Posted by Legacy on 09/24/1999 12:00am

    Originally posted by: Doc Davies

    I set the LVS_EX_FULLROWSELECT on a listview in VB6, when I had a column which was right aligned and contained an empty value, the full row select didn't work proberly.


    Posted by Legacy on 07/19/1999 12:00am

    Originally posted by: Stefan Niermann

    LVM_SETEXTENDEDLISTVIEWSTYLE allows the modification of only one or more styles by passing a style mask in the wParam.

    m_listctrl.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, dwStyle, dwStyle) modifies only one style without retrieving the current styles.


  • Q:How Can I make a ListView with radio button in each grid?

    Posted by Legacy on 05/03/1999 12:00am

    Originally posted by: Lee Sung-Yub

    I'm programmer in Korea..

    I'm trying to find how to make a ListView with radio button in Each Grid.

    Programming Spec is simple, Some Kind of Event occurred by User, My program have to check what grid is checked and do something....

    but it was not simple to implement it...

    Samples in this web site, seems only to mention about ListView with Column selectable ListView or Row selectable ListView.

    But how about Grid(row/column) selectable ListView?

    And if there is any method to solve that problem and that uses comctl32.dll, please answer me what version of comctl32.dll supports it...

    I'm poor English composer..., so if there is any wrong expression in this text, please understand my text with great kindness...

    and I'm sincerely waiting for your answer.. and thanks in advance...

  • Bug in combination of FullRow and Gridlines ?

    Posted by Legacy on 04/12/1999 12:00am

    Originally posted by: Daniel Schmid

    When I use LVS_EX_FULLROWSELECT and LVS_EX_GRIDLINES as extended styles, the first row is less height than the following ones. By selecting a row, the selection rectangle is shifted down for the amount of pixels the first row is smaller.
    How can this be fixed?

  • How do you take advantage of the LVS_EX_SUBITEMIMAGES ex_style?

    Posted by Legacy on 01/13/1999 12:00am

    Originally posted by: Kevin Treanor

    How do you use LVS_EX_SUBITEMIMAGES flag. I can't seem to get a image in a sub item.

    Thanks in advance


  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • A leading provider of tools and services to the health care industry was looking to implement automated chargeback reports with aggregation of tiered storage usage across multiple business units and applications. When the company's storage administrators attempted to create this system in-house, their productivity took a huge hit and they discovered the task was too challenging, as well. Read this case study to learn how this company was able to increase storage utilization, reduce storage consumption, and …

  • IDC estimates that more than 70% of organizations have a cloud-first application deployment strategy to align with digital transformation initiatives. As such, many organizations are transitioning to Microsoft Office 365 and utilizing public clouds such as Microsoft Azure. However, IT leaders are discovering that default data protection schemes are not as robust as they desire. As a result, many are turning to Veeam® to provide the necessary data management and protection policies demanded by the …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date