{"id":112037,"date":"2026-02-04T07:00:00","date_gmt":"2026-02-04T15:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=112037"},"modified":"2026-02-04T07:24:27","modified_gmt":"2026-02-04T15:24:27","slug":"20260204-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20260204-00\/?p=112037","title":{"rendered":"How can I prevent the user from changing the widths of ListView columns?"},"content":{"rendered":"<p>Suppose you are using a Win32 ListView control in report mode, and you&#8217;ve got all your columns set up perfectly, and you don&#8217;t want the user to resize them. How do you do that?<\/p>\n<p>There is no ListView style for preventing column resize, but there <i>is<\/i> a header control style to prevent sizing: <code>HDS_NOSIZING<\/code>. This style requires Common Controls version 6, but I&#8217;m sure you&#8217;re all using that version already, right?<\/p>\n<pre>auto hdr = ListView_GetHeader(hwndLV);\r\nSetWindowLong(hdr, GWL_STYLE,\r\n              GetWindowLong(hdr, GWL_STYLE) | HDS_NOSIZING);\r\n<\/pre>\n<p>Whether the columns can be resized is independent of whether the columns can be rearranged, which you specify by setting the <code>LVS_<wbr \/>EX_<wbr \/>HEADER\u00adDRAG\u00adDROP<\/code> ListView extended style.<\/p>\n<pre>ListView_SetExtendedListViewStyleEx(hwndLV,\r\n                                    LVS_EX_HEADERDRAGDROP,\r\n                                    LVS_EX_HEADERDRAGDROP);\r\n<\/pre>\n<p>Okay, but what if you&#8217;re stuck in the dark ages with version 5 of the Common Controls? We&#8217;ll look at that next time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can ask the header to be non-resizing.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-112037","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>You can ask the header to be non-resizing.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/112037","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=112037"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/112037\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=112037"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=112037"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=112037"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}