Remember wxBitmapComboBox selection when recreating the control

Recreate the control with the correct height when adding the first item with bitmap.
This commit is contained in:
Maarten Bent 2019-09-28 23:00:33 +02:00
parent 092d507714
commit 459ffcff61

View File

@ -127,6 +127,7 @@ void wxBitmapComboBox::RecreateControl()
// mouse-wheel behaviour.
//
wxString value = GetValue();
int selection = GetSelection();
wxPoint pos = GetPosition();
wxSize size = GetSize();
size.y = GetBestSize().y;
@ -210,6 +211,8 @@ void wxBitmapComboBox::RecreateControl()
// Revert the old string value
if ( !HasFlag(wxCB_READONLY) )
ChangeValue(value);
else if ( selection != wxNOT_FOUND )
SetSelection(selection);
// If disabled we'll have to disable it again after re-creating
if ( !IsEnabled() )
@ -407,7 +410,7 @@ int wxBitmapComboBox::DoInsertItems(const wxArrayStringsAdapter & items,
bool wxBitmapComboBox::OnAddBitmap(const wxBitmap& bitmap)
{
if ( wxBitmapComboBoxBase::OnAddBitmap(bitmap) )
if ( wxBitmapComboBoxBase::OnAddBitmap(bitmap) || !GetCount() )
{
// Need to recreate control for a new measureitem call?
int prevItemHeight = ::SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0);