X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e558f9533e5e628efef8027b2434c00f3d4ed8cf..edae63b0769fab90e3a64d0e211ae3090b6120c8:/src/msw/combobox.cpp?ds=inline diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp index eda21ff9c6..9537a60acc 100644 --- a/src/msw/combobox.cpp +++ b/src/msw/combobox.cpp @@ -438,11 +438,7 @@ bool wxComboBox::MSWShouldPreProcessMessage(WXMSG *pMsg) WXHWND wxComboBox::GetEditHWNDIfAvailable() const { - // notice that a slightly safer alternative could be to use FindWindowEx() - // but it's not available under WinCE so just take the first child for now - // to keep one version of the code for all platforms and fix it later if - // problems are discovered - +#if defined(WINVER) && WINVER >= 0x0500 typedef BOOL (WINAPI *GetComboBoxInfo_t)(HWND, COMBOBOXINFO*); static GetComboBoxInfo_t s_pfnGetComboBoxInfo = NULL; static bool s_triedToLoad = false; @@ -459,6 +455,7 @@ WXHWND wxComboBox::GetEditHWNDIfAvailable() const (*s_pfnGetComboBoxInfo)(GetHwnd(), &info); return info.hwndItem; } +#endif if (HasFlag(wxCB_SIMPLE)) { @@ -467,6 +464,11 @@ WXHWND wxComboBox::GetEditHWNDIfAvailable() const return (WXHWND) ::ChildWindowFromPoint(GetHwnd(), pt); } + // notice that a slightly safer alternative could be to use FindWindowEx() + // but it's not available under WinCE so just take the first child for now + // to keep one version of the code for all platforms and fix it later if + // problems are discovered + // we assume that the only child of the combobox is the edit window return (WXHWND)::GetWindow(GetHwnd(), GW_CHILD); } @@ -700,6 +702,22 @@ 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)