const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0);
height += hItem*(nItems + 1);
}
-
- // To work around a Windows bug (see "Bug in Windows Combobox" thread in Google Groups)
- // we have to reset the selection if it was accidentally selected in the size.
- DWORD oldSelStart = 0;
- DWORD oldSelEnd = 0;
- DWORD newSelStart = 0;
- DWORD newSelEnd = 0;
-
- ::SendMessage(GetHwnd(), CB_GETEDITSEL, (WPARAM) & oldSelStart, (LPARAM) & oldSelEnd);
-
- wxControl::DoSetSize(x, y, width, height, sizeFlags);
-
- ::SendMessage(GetHwnd(), CB_GETEDITSEL, (WPARAM) & newSelStart, (LPARAM) & newSelEnd);
-
- if (oldSelStart != newSelStart || oldSelEnd != newSelEnd)
+ else
{
- ::SendMessage(GetHwnd(), CB_SETEDITSEL, (WPARAM) 0, (LPARAM) MAKELPARAM(oldSelStart, oldSelEnd));
+ // We cannot pass wxDefaultCoord as height to wxControl. wxControl uses
+ // wxGetWindowRect() to determine the current height of the combobox,
+ // and then again sets the combobox's height to that value. Unfortunately,
+ // wxGetWindowRect doesn't include the dropdown list's height (at least
+ // on Win2K), so this would result in a combobox with dropdown height of
+ // 1 pixel. We have to determine the default height ourselves and call
+ // wxControl with that value instead.
+ int w, h;
+ RECT r;
+ DoGetSize(&w, &h);
+ if (::SendMessage(GetHwnd(), CB_GETDROPPEDCONTROLRECT, 0, (LPARAM) &r) != 0)
+ {
+ height = h + r.bottom - r.top;
+ }
}
+ wxControl::DoSetSize(x, y, width, height, sizeFlags);
+
// I'm commenting this out since the code appears to make choices
// and comboxes too high when they have associated sizers. I'm sure this
// is not the end of the story, which is why I'm leaving it #if'ed out for