+ // don't make the drop down list too tall, arbitrarily limit it to 30
+ // items max and also don't make it too small if it's currently empty
+ size_t nItems = GetCount();
+ if (!HasFlag(wxCB_SIMPLE))
+ {
+ if ( !nItems )
+ nItems = 9;
+ else if ( nItems > 30 )
+ nItems = 30;
+ }
+
+ const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0);
+ int heightWithItems = 0;
+ if (!HasFlag(wxCB_SIMPLE))
+ // 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);
+ else
+ heightWithItems = SetHeightSimpleComboBox(nItems);
+
+
+ // do resize the native control
+ wxControl::DoSetSize(x, y, width, heightWithItems, sizeFlags);
+
+
+ // make the control itself of the requested height: notice that this
+ // must be done after changing its size or it has no effect (apparently
+ // the height is reset to default during the control layout) and that it's
+ // useless to do it when using the deferred sizing -- in this case it
+ // will be done from MSWEndDeferWindowPos()
+#if wxUSE_DEFERRED_SIZING
+ if ( m_pendingSize == wxDefaultSize )
+ {
+ // not using deferred sizing, update it immediately
+ MSWUpdateVisibleHeight();
+ }
+ else // in the middle of deferred sizing
+ {
+ // we need to report the size of the visible part of the control back
+ // in GetSize() and not height stored by DoSetSize() in m_pendingSize
+ m_pendingSize = wxSize(width, height);
+ }
+#else // !wxUSE_DEFERRED_SIZING
+ // always update the visible height immediately
+ MSWUpdateVisibleHeight();
+#endif // wxUSE_DEFERRED_SIZING