diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 7c8369e5ed..8e2dc51f8d 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1611,10 +1611,16 @@ wxSize wxListCtrl::MSWGetBestViewRect(int x, int y) const if ( mswStyle & WS_VSCROLL ) size.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, m_parent); - // OTOH we have to subtract the size of our borders because the base class - // public method already adds them, but ListView_ApproximateViewRect() - // already takes the borders into account, so this would be superfluous. - return size - GetWindowBorderSize(); + // This is a dirty hack, but while the size returned by the control does + // fit its contents, it results in asymmetric horizontal margins around it, + // with 3px on one side and just 1px on the other one. Adding these 2px + // makes it looks nicely symmetrical, at least under Windows 7 and 10. + // Vertical margins are even more asymmetric, but they're too big and not + // too small and it might be a bad idea to allocate size smaller than what + // the control thinks it needs, so leave them be. + size.IncBy(2, 0); + + return size; } // ----------------------------------------------------------------------------