void AFXAPI AfxCancelModes(HWND hWndRcvr) { // if we receive a message destined for a window, cancel any combobox // popups that could be in toolbars or dialog bars HWND hWndCancel = ::GetFocus(); if (hWndCancel == NULL) return; // nothing to cancel if (hWndCancel == hWndRcvr) return; // let input go to window with focus // focus is in part of a combo-box if (!_AfxIsComboBoxControl(hWndCancel, (UINT)CBS_DROPDOWNLIST)) { // check as a dropdown hWndCancel = ::GetParent(hWndCancel); // parent of edit is combo if (hWndCancel == hWndRcvr) return; // let input go to part of combo if (!_AfxIsComboBoxControl(hWndCancel, (UINT)CBS_DROPDOWN)) return; // not a combo-box that is active } // combo-box is active, but if receiver is a popup, do nothing if (hWndRcvr != NULL && (::GetWindowLong(hWndRcvr, GWL_STYLE) & WS_CHILD) != 0 && ::GetParent(hWndRcvr) == ::GetDesktopWindow()) return; // finally, we should cancel the mode! ::SendMessage(hWndCancel, CB_SHOWDROPDOWN, FALSE, 0L); }
LRESULT CToolTipCtrl::OnWindowFromPoint(WPARAM, LPARAM lParam) { ASSERT(lParam != NULL); // the default implementation of tooltips just calls WindowFromPoint // which does not work for certain kinds of combo boxes CPoint pt = *(POINT*)lParam; HWND hWnd = ::WindowFromPoint(pt); if (hWnd == NULL) return 0; // try to hit combobox instead of edit control for CBS_DROPDOWN styles HWND hWndTemp = ::GetParent(hWnd); if (hWndTemp != NULL && _AfxIsComboBoxControl(hWndTemp, CBS_DROPDOWN)) return (LRESULT)hWndTemp; // handle special case of disabled child windows ::ScreenToClient(hWnd, &pt); hWndTemp = _AfxChildWindowFromPoint(hWnd, pt); if (hWndTemp != NULL && !::IsWindowEnabled(hWndTemp)) return (LRESULT)hWndTemp; return (LRESULT)hWnd; }