// 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())
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;
}