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
This commit is contained in:
parent
cca1624d2a
commit
0b652e0ef9
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user