+ return (wxClientData *)DoGetItemClientData(n);
+}
+
+// ----------------------------------------------------------------------------
+// wxMSW specific helpers
+// ----------------------------------------------------------------------------
+
+void wxChoice::DoMoveWindow(int x, int y, int width, int height)
+{
+ // here is why this is necessary: if the width is negative, the combobox
+ // window proc makes the window of the size width*height instead of
+ // interpreting height in the usual manner (meaning the height of the drop
+ // down list - usually the height specified in the call to MoveWindow()
+ // will not change the height of combo box per se)
+ //
+ // this behaviour is not documented anywhere, but this is just how it is
+ // here (NT 4.4) and, anyhow, the check shouldn't hurt - however without
+ // the check, constraints/sizers using combos may break the height
+ // constraint will have not at all the same value as expected
+ if ( width < 0 )
+ return;
+
+ wxControl::DoMoveWindow(x, y, width, height);
+}
+
+void wxChoice::DoSetSize(int x, int y,
+ int width, int WXUNUSED(height),
+ int sizeFlags)
+{
+ // Ignore height parameter because height doesn't mean 'initially
+ // displayed' height, it refers to the drop-down menu as well. The
+ // wxWindows interpretation is different; also, getting the size returns
+ // the _displayed_ size (NOT the drop down menu size) so
+ // setting-getting-setting size would not work.
+
+ wxControl::DoSetSize(x, y, width, -1, sizeFlags);
+}
+
+wxSize wxChoice::DoGetBestSize() const
+{
+ // find the widest string
+ int wLine;
+ int wChoice = 0;
+ int nItems = GetCount();
+ for ( int i = 0; i < nItems; i++ )
+ {
+ wxString str(GetString(i));
+ GetTextExtent(str, &wLine, NULL);
+ if ( wLine > wChoice )
+ wChoice = wLine;
+ }
+
+ // give it some reasonable default value if there are no strings in the
+ // list
+ if ( wChoice == 0 )
+ wChoice = 100;
+
+ // the combobox should be larger than the widest string
+ int cx, cy;
+ wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
+
+ wChoice += 5*cx;
+
+ // Choice drop-down list depends on number of items (limited to 10)
+ size_t nStrings = nItems == 0 ? 10 : wxMin(10, nItems) + 1;
+ int hChoice = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*nStrings;
+
+ return wxSize(wChoice, hChoice);