From 0e0ea2ad848c31de16f2efd64305035411138789 Mon Sep 17 00:00:00 2001 From: oneeyeman1 Date: Sat, 28 Sep 2019 14:47:57 -0500 Subject: [PATCH] Fix autosizing empty columns in wxMSW wxListCtrl Autosizing the column by double clicking on its separator line reset it to the default width when the control was empty, which isn't especially useful. Set the column size to fit its header instead. Closes #9926. See https://github.com/wxWidgets/wxWidgets/pull/1573 --- src/msw/listctrl.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index aa5afe781c..e9feef55b4 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -2290,6 +2290,21 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) event.m_col = nmHDR->iItem; break; + case HDN_DIVIDERDBLCLICK: + { + NMHEADER *pHeader = (NMHEADER *) lParam; + // If the control is non-empty, the native control will + // autosize the column to its contents, however if it is empty, + // it just resets it to some default width, while we want to + // still autosize it in this case, to fit its label width. + if ( IsEmpty() ) + { + SetColumnWidth(pHeader->iItem, wxLIST_AUTOSIZE_USEHEADER); + return true; + } + } + break; + case NM_RCLICK: { POINT ptClick;