February 4th, 2026
like1 reaction

How can I prevent the user from changing the widths of ListView columns?

Suppose you are using a Win32 ListView control in report mode, and you’ve got all your columns set up perfectly, and you don’t want the user to resize them. How do you do that?

There is no ListView style for preventing column resize, but there is a header control style to prevent sizing: HDS_NOSIZING. This style requires Common Controls version 6, but I’m sure you’re all using that version already, right?

auto hdr = ListView_GetHeader(hwndLV);
SetWindowLong(hdr, GWL_STYLE,
              GetWindowLong(hdr, GWL_STYLE) | HDS_NOSIZING);

Whether the columns can be resized is independent of whether the columns can be rearranged, which you specify by setting the LVS_EX_HEADER­DRAG­DROP ListView extended style.

ListView_SetExtendedListViewStyleEx(hwndLV,
                                    LVS_EX_HEADERDRAGDROP,
                                    LVS_EX_HEADERDRAGDROP);

Okay, but what if you’re stuck in the dark ages with version 5 of the Common Controls? We’ll look at that next time.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

2 comments

Sort by :
  • Joshua Hudson 59 minutes ago · Edited

    Two reasons you might still be on Common Controls version 5:

    1) You are developing a GUI application that runs on Server Core. Trust me, this is sensible. The GUI application is an oversized dialog box for configuring the service. (There is automation. Unless you are managing more than one it's a lot easier to open the GUI application than use the automation.) Common Controls 5 works better than 6 on Server Core. (We had to write a bit of code because checkboxes misrender (probably due to a missing font), but it's far less than the alternative.)

    2) You've hit one of...

    Read more
  • Marek Knápek 1 hour ago

    Do you still get the old version 5.82 of common controls if your application doesn’t have any manifest? Even on modern Windows? Meaning the header control doesn’t understand the style?