From: Julian Smart Date: Thu, 23 Mar 2006 15:28:02 +0000 (+0000) Subject: Added an optimization that fixes a recursive paint problem when controls X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/0b652e0ef9fd1c007ef64b1ab1a1a00626e04ae5 Added an optimization that fixes a recursive paint problem when controls are embedded in wxHTML (or other circumstances where the parent resizes the choice/combobox within a paint handler). This also speeds up addition of strings considerably (see "Add many strings" in widgets sample). Also added a check for silly values that can be returned from CB_GETDROPPEDCONTROLRECT. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38301 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index 7c15b52d83..c1e6fb31db 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -511,17 +511,28 @@ void wxChoice::DoSetSize(int x, int y, // is, of course, just the height of the permanently visible part of it if ( height != wxDefaultCoord ) { - // don't make the drop down list too tall, arbitrarily limit it to 40 - // items max and also don't leave it empty - size_t nItems = GetCount(); - if ( !nItems ) - nItems = 9; - else if ( nItems > 24 ) - nItems = 24; - - // add space for the drop down list - const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0); - height += hItem*(nItems + 1); + int w, h; + DoGetSize(&w, &h); + + // Don't change the height if it's already this size + if (h == height) + { + height = -1; + } + else + { + // don't make the drop down list too tall, arbitrarily limit it to 40 + // items max and also don't leave it empty + size_t nItems = GetCount(); + if ( !nItems ) + nItems = 9; + else if ( nItems > 24 ) + nItems = 24; + + // add space for the drop down list + const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0); + height += hItem*(nItems + 1); + } } else { @@ -535,7 +546,7 @@ void wxChoice::DoSetSize(int x, int y, int w, h; RECT r; DoGetSize(&w, &h); - if (::SendMessage(GetHwnd(), CB_GETDROPPEDCONTROLRECT, 0, (LPARAM) &r) != 0) + if (::SendMessage(GetHwnd(), CB_GETDROPPEDCONTROLRECT, 0, (LPARAM) &r) != 0 && r.bottom < 30000) { height = h + r.bottom - r.top; }