]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/radiobox.cpp
check that the version of __sync_sub_and_fetch that returns a value is supported...
[wxWidgets.git] / src / msw / radiobox.cpp
index 408c5d8b65d51104152a662afd6be9538380d0c0..b29e5eb3e23f71faedddc9fef2736ea56a99535e 100644 (file)
@@ -258,8 +258,10 @@ void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn)
 // events generation
 // ----------------------------------------------------------------------------
 
-bool wxRadioBox::MSWCommand(WXUINT cmd, WXWORD id)
+bool wxRadioBox::MSWCommand(WXUINT cmd, WXWORD id_)
 {
+    const int id = (signed short)id_;
+
     if ( cmd == BN_CLICKED )
     {
         if (id == GetId())
@@ -270,9 +272,14 @@ bool wxRadioBox::MSWCommand(WXUINT cmd, WXWORD id)
         const unsigned int count = GetCount();
         for ( unsigned int i = 0; i < count; i++ )
         {
-            if ( id == wxGetWindowId((*m_radioButtons)[i]) )
+            const HWND hwndBtn = (*m_radioButtons)[i];
+            if ( id == wxGetWindowId(hwndBtn) )
             {
-                selectedButton = i;
+                // we can get BN_CLICKED for a button which just became focused
+                // but it may not be checked, in which case we shouldn't
+                // generate a radiobox selection changed event for it
+                if ( ::SendMessage(hwndBtn, BM_GETCHECK, 0, 0) == BST_CHECKED )
+                    selectedButton = i;
 
                 break;
             }