else
{
int pos = (int)SendMessage(GetHwnd(), CB_FINDSTRINGEXACT,
- (WPARAM)-1, (LPARAM)s.wx_str());
+ (WPARAM)-1, wxMSW_CONV_LPARAM(s));
return pos == LB_ERR ? wxNOT_FOUND : pos;
}
const bool wasSelected = static_cast<int>(n) == GetSelection();
::SendMessage(GetHwnd(), CB_DELETESTRING, n, 0);
- ::SendMessage(GetHwnd(), CB_INSERTSTRING, n, (LPARAM)s.wx_str() );
+ ::SendMessage(GetHwnd(), CB_INSERTSTRING, n, wxMSW_CONV_LPARAM(s) );
// restore the client data
if ( oldData )
return EDIT_HEIGHT_FROM_CHAR_HEIGHT( cy ) * wxMin( wxMax( nItems, 3 ), 6 ) + hItem - 1;
}
+// ----------------------------------------------------------------------------
+// Popup operations
+// ----------------------------------------------------------------------------
+
+void wxChoice::MSWDoPopupOrDismiss(bool show)
+{
+ wxASSERT_MSG( !HasFlag(wxCB_SIMPLE),
+ wxT("can't popup/dismiss the list for simple combo box") );
+
+ // we *must* set focus to the combobox before showing or hiding the drop
+ // down as without this we get WM_LBUTTONDOWN messages with invalid HWND
+ // when hiding it (whether programmatically or manually) resulting in a
+ // crash when we pass them to IsDialogMessage()
+ //
+ // this can be seen in the combo page of the widgets sample under Windows 7
+ SetFocus();
+
+ ::SendMessage(GetHwnd(), CB_SHOWDROPDOWN, show, 0);
+}
+
+bool wxChoice::Show(bool show)
+{
+ if ( !wxChoiceBase::Show(show) )
+ return false;
+
+ // When hiding the combobox, we also need to hide its popup part as it
+ // doesn't happen automatically.
+ if ( !show && ::SendMessage(GetHwnd(), CB_GETDROPPEDSTATE, 0, 0) )
+ MSWDoPopupOrDismiss(false);
+
+ return true;
+}
+
// ----------------------------------------------------------------------------
// MSW message handlers
// ----------------------------------------------------------------------------
WXHBRUSH wxChoice::MSWControlColor(WXHDC hDC, WXHWND hWnd)
{
- if ( !IsEnabled() )
+ if ( !IsThisEnabled() )
return MSWControlColorDisabled(hDC);
return wxChoiceBase::MSWControlColor(hDC, hWnd);