OnAutoSizeColumns improvement

Discuss development issues and submit patches here
Post Reply
Edgar5
Posts: 63
Joined: Sun Apr 02, 2017 7:22 am

OnAutoSizeColumns improvement

Post by Edgar5 »

In file:
\Explorer++\MsgHandler.cpp
at or near line #1600 the old Explorerplusplus::OnAutoSizeColumns () logic ignored the possibility that the header text could be wider than the widest item in the column. This sizes the columns based on the widest of either the header or the widest item.

Code: Select all

void Explorerplusplus::OnAutoSizeColumns(void) {
   // re-spelled; made sizing wide enough for the maximum of header or items width
	size_t nColumns = m_pActiveShellBrowser->QueryNumActiveColumns();
   // nColumns is usually larger than the real number of columns displayed

   for (UINT column = 0; column < nColumns; column++) {
      ListView_SetColumnWidth(m_hActiveListView, column, LVSCW_AUTOSIZE_USEHEADER);
      int headerWidth = ListView_GetColumnWidth(m_hActiveListView, column);
      ListView_SetColumnWidth(m_hActiveListView, column, LVSCW_AUTOSIZE);
      int itemsWidth = ListView_GetColumnWidth(m_hActiveListView, column);
      if ((headerWidth == 0) && (itemsWidth == 0)) {
         break;
      }
      else {
         ListView_SetColumnWidth(m_hActiveListView, column, max(headerWidth, itemsWidth));
      }
   }
}
-Edgar5

Post Reply