From ddd761f2d95e708f8b0107de4961e24a77c27773 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 20 Jan 2014 14:44:44 +0000 Subject: [PATCH] Ensure wxChoice reported width never becomes negative in wxMSW. Don't set the pending size to (-1, valid-height) as it is always supposed to be either fully valid or fully invalid (meaning there is no pending size change). Closes #15723. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75654 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/choice.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index 6699e1e95b..f74d647da2 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -533,15 +533,16 @@ void wxChoice::DoSetSize(int x, int y, int width, int height, int sizeFlags) { - const int heightBest = GetBestSize().y; + // The height of the control itself, i.e. of its visible part. + int heightVisible = height; // we need the real height below so get the current one if it's not given if ( height == wxDefaultCoord ) { // height not specified, use the same as before - DoGetSize(NULL, &height); + DoGetSize(NULL, &heightVisible); } - else if ( height == heightBest ) + else if ( height == GetBestSize().y ) { // we don't need to manually manage our height, let the system use the // default one @@ -585,7 +586,7 @@ void wxChoice::DoSetSize(int x, int y, // The extra item (" + 1") is required to prevent a vertical // scrollbar from appearing with comctl32.dll versions earlier // than 6.0 (such as found in Win2k). - heightWithItems = height + hItem*(nItems + 1); + heightWithItems = heightVisible + hItem*(nItems + 1); else heightWithItems = SetHeightSimpleComboBox(nItems);