+wxSize wxListBox::DoGetBestSize()
+{
+ // find the widest string
+ int wLine;
+ int wListbox = 0;
+ for ( int i = 0; i < m_noItems; i++ )
+ {
+ wxString str(GetString(i));
+ GetTextExtent(str, &wLine, NULL);
+ if ( wLine > wListbox )
+ wListbox = wLine;
+ }
+
+ // give it some reasonable default value if there are no strings in the
+ // list
+ if ( wListbox == 0 )
+ wListbox = 100;
+
+ // the listbox should be slightly larger than the widest string
+ int cx, cy;
+ wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
+
+ wListbox += 3*cx;
+
+ int hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*(wxMax(m_noItems, 7));
+
+ return wxSize(wListbox, hListbox);
+}
+