]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/checklst.cpp
check that the version of __sync_sub_and_fetch that returns a value is supported...
[wxWidgets.git] / src / msw / checklst.cpp
index 933537bc1b5981d6c6f98a04d0dc5c6d3f20e17c..1ac17a442043ca61afc6fee4621b63c5316dff59 100644 (file)
@@ -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
     }