X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c70557da0876955e9fab33939c47a697c85bcb65..9d5507f7a2701395e1d5c121bd877bb9066ee6ea:/src/msw/checklst.cpp?ds=sidebyside diff --git a/src/msw/checklst.cpp b/src/msw/checklst.cpp index 65325be752..1ac17a4420 100644 --- a/src/msw/checklst.cpp +++ b/src/msw/checklst.cpp @@ -124,7 +124,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox) class wxCheckListBoxItem : public wxOwnerDrawn { -friend class WXDLLEXPORT wxCheckListBox; +friend class WXDLLIMPEXP_FWD_CORE wxCheckListBox; public: // ctor wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex); @@ -174,8 +174,9 @@ bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc, if ( !wxOwnerDrawn::OnDrawItem(dc, rc, act, stat) ) return false; + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); // now draw the check mark part - HDC hdc = GetHdcOf(dc); + HDC hdc = GetHdcOf(*impl); int nBmpWidth = ::GetSystemMetrics(SM_CXMENUCHECK), nBmpHeight = ::GetSystemMetrics(SM_CYMENUCHECK); @@ -483,9 +484,19 @@ void wxCheckListBox::OnLeftClick(wxMouseEvent& event) if ( nItem != wxNOT_FOUND ) { - wxCheckListBoxItem *item = GetItem(nItem); - item->Toggle(); - item->SendEvent(); + // people expect to get "kill focus" event for the currently + // focused control before getting events from the other controls + // and, equally importantly, they may prevent the focus change from + // taking place at all (e.g. because the old control contents is + // invalid and needs to be corrected) in which case we shouldn't + // generate this event at all + SetFocus(); + if ( FindFocus() == this ) + { + wxCheckListBoxItem *item = GetItem(nItem); + item->Toggle(); + item->SendEvent(); + } } //else: it's not an error, just click outside of client zone }