+ size_t nLen = 0;
+ wxString sStr = "";
+ char* zBuf;
+
+ nLen = (size_t)LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)n, (MPARAM)0));
+ if (nLen != LIT_ERROR && nLen > 0)
+ {
+ zBuf = new char[nLen + 1];
+ ::WinSendMsg( GetHwnd()
+ ,LM_QUERYITEMTEXT
+ ,MPFROM2SHORT((SHORT)n, (SHORT)nLen)
+ ,(MPARAM)zBuf
+ );
+ sStr = zBuf;
+ delete [] zBuf;
+ }
+ return sStr;
+} // end of wxChoice::GetString
+
+// ----------------------------------------------------------------------------
+// client data
+// ----------------------------------------------------------------------------
+
+void wxChoice::DoSetItemClientData(
+ int n
+, void* pClientData
+)
+{
+ ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, (MPARAM)n, MPFROMP(pClientData));
+} // end of wxChoice::DoSetItemClientData
+
+void* wxChoice::DoGetItemClientData( int n ) const
+{
+ MRESULT rc = 0L;
+
+ rc = ::WinSendMsg(GetHwnd(), LM_QUERYITEMHANDLE, (MPARAM)n, (MPARAM)0);
+ return((void*)rc);
+} // end of wxChoice::DoSetItemClientData
+
+void wxChoice::DoSetItemClientObject(
+ int n
+, wxClientData* pClientData
+)
+{
+ DoSetItemClientData( n
+ ,pClientData
+ );
+} // end of wxChoice::DoSetItemClientObject
+
+wxClientData* wxChoice::DoGetItemClientObject(
+ int n
+) const
+{
+ return (wxClientData *)DoGetItemClientData(n);
+} // end of wxChoice::DoGetItemClientObject
+
+// ----------------------------------------------------------------------------
+// wxOS2 specific helpers
+// ----------------------------------------------------------------------------
+
+void wxChoice::DoSetSize(
+ int nX
+, int nY
+, int nWidth
+, int nHeight
+, int nSizeFlags
+)
+{
+ //
+ // 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( nX
+ ,nY
+ ,nWidth
+ ,-1
+ ,nSizeFlags
+ );
+} // end of wxChoice::DoSetSize
+
+wxSize wxChoice::DoGetBestSize() const
+{
+ //
+ // Find the widest string
+ //
+ int nLineWidth;
+ int nChoiceWidth = 0;
+ int nItems = GetCount();
+ int nCx;
+ int nCy;
+
+ for (int i = 0; i < nItems; i++)
+ {
+ wxString sStr(GetString(i));
+
+ GetTextExtent( sStr
+ ,&nLineWidth
+ ,NULL
+ );
+ if (nLineWidth > nChoiceWidth)
+ nChoiceWidth = nLineWidth;
+ }
+
+ //
+ // Give it some reasonable default value if there are no strings in the
+ // list
+ //
+ if (nChoiceWidth == 0L)
+ nChoiceWidth = 100L;
+
+ //
+ // The combobox should be larger than the widest string
+ //
+ wxGetCharSize( GetHWND()
+ ,&nCx
+ ,&nCy
+ ,(wxFont*)&GetFont()
+ );
+ nChoiceWidth += 5 * nCx;
+
+ //
+ // Choice drop-down list depends on number of items (limited to 10)
+ //
+ size_t nStrings = nItems == 0 ? 10 : wxMin(10, nItems) + 1;
+ int nChoiceHeight = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy) * nStrings;
+
+ return wxSize( nChoiceWidth
+ ,nChoiceHeight
+ );
+} // end of wxChoice::DoGetBestSize
+
+MRESULT wxChoice::OS2WindowProc(
+ WXUINT uMsg
+, WXWPARAM wParam
+, WXLPARAM lParam
+)
+{
+ return wxWindow::OS2WindowProc( uMsg
+ ,wParam
+ ,lParam
+ );
+} // end of wxChoice::OS2WindowProc
+
+bool wxChoice::OS2Command(
+ WXUINT uParam
+, WXWORD WXUNUSED(wId)
+)
+{
+ if (uParam != LN_SELECT)
+ {
+ //
+ // "selection changed" is the only event we're after
+ //