From a24fb9f847872e6ab2edf4be3e258245cbd8f20c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 5 Apr 2012 18:40:15 +0000 Subject: [PATCH] Refactor: move wxComboBox::MSWDoPopupOrDismiss() down to wxChoice. No real changes, just make this method available in wxChoice for the next commit needs. See #3113. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71103 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/choice.h | 3 +++ include/wx/msw/combobox.h | 1 - src/msw/choice.cpp | 20 ++++++++++++++++++++ src/msw/combobox.cpp | 16 ---------------- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/include/wx/msw/choice.h b/include/wx/msw/choice.h index c5cf8125be..ec7d272651 100644 --- a/include/wx/msw/choice.h +++ b/include/wx/msw/choice.h @@ -124,6 +124,9 @@ protected: int width, int height, int sizeFlags = wxSIZE_AUTO); + // Show or hide the popup part of the control. + void MSWDoPopupOrDismiss(bool show); + // update the height of the drop down list to fit the number of items we // have (without changing the visible height) void MSWUpdateDropDownHeight(); diff --git a/include/wx/msw/combobox.h b/include/wx/msw/combobox.h index 4f4a99458b..191ebb3f90 100644 --- a/include/wx/msw/combobox.h +++ b/include/wx/msw/combobox.h @@ -130,7 +130,6 @@ protected: #if wxUSE_TOOLTIPS virtual void DoSetToolTip(wxToolTip *tip); #endif - void MSWDoPopupOrDismiss(bool show); // this is the implementation of GetEditHWND() which can also be used when // we don't have the edit control, it simply returns NULL then diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index 74ec10a47b..650dff48ce 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -626,6 +626,26 @@ int wxChoice::SetHeightSimpleComboBox(int nItems) const 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); +} + // ---------------------------------------------------------------------------- // MSW message handlers // ---------------------------------------------------------------------------- diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp index 1b99ac7f0f..9e3f75edd7 100644 --- a/src/msw/combobox.cpp +++ b/src/msw/combobox.cpp @@ -642,22 +642,6 @@ void wxComboBox::OnUpdateSelectAll(wxUpdateUIEvent& event) event.Enable(IsEditable() && !wxTextEntry::IsEmpty()); } -void wxComboBox::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); -} - #if wxUSE_TOOLTIPS void wxComboBox::DoSetToolTip(wxToolTip *tip) -- 2.45.2