X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bf511d579fb186e8f5ec7a0dc933a5c0df10902d..3371873669823e49ac8b01e67711e453252eaa23:/src/msw/radiobox.cpp diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index f73e2ba3c2..7865639116 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -129,6 +129,7 @@ void wxRadioBox::Init() { m_selectedButton = wxNOT_FOUND; m_radioButtons = NULL; + m_radioButtonIds = NULL; m_radioWidth = NULL; m_radioHeight = NULL; } @@ -156,6 +157,7 @@ bool wxRadioBox::Create(wxWindow *parent, #endif // wxUSE_VALIDATORS/!wxUSE_VALIDATORS m_radioButtons = new wxSubwindows(n); + m_radioButtonIds = new wxWindowIDRef[n + 1]; m_radioWidth = new int[n]; m_radioHeight = new int[n]; @@ -167,14 +169,14 @@ bool wxRadioBox::Create(wxWindow *parent, if ( i == 0 ) styleBtn |= WS_GROUP; - long newId = NewControlId(); + m_radioButtonIds[i] = NewControlId(); HWND hwndBtn = ::CreateWindow(_T("BUTTON"), choices[i].wx_str(), styleBtn, 0, 0, 0, 0, // will be set in SetSize() GetHwndOf(parent), - (HMENU)newId, + (HMENU)(wxWindowID)m_radioButtonIds[i], wxGetInstance(), NULL); @@ -189,15 +191,17 @@ bool wxRadioBox::Create(wxWindow *parent, SubclassRadioButton((WXHWND)hwndBtn); - m_subControls.Add(newId); + m_subControls.Add(m_radioButtonIds[i]); } // Create a dummy radio control to end the group. + m_radioButtonIds[n] = NewControlId(); + (void)::CreateWindow(_T("BUTTON"), wxEmptyString, WS_GROUP | BS_AUTORADIOBUTTON | WS_CHILD, 0, 0, 0, 0, GetHwndOf(parent), - (HMENU)NewControlId(), wxGetInstance(), NULL); + (HMENU)(wxWindowID)m_radioButtonIds[n], wxGetInstance(), NULL); m_radioButtons->SetFont(GetFont()); @@ -237,6 +241,7 @@ wxRadioBox::~wxRadioBox() m_isBeingDeleted = true; delete m_radioButtons; + delete[] m_radioButtonIds; delete[] m_radioWidth; delete[] m_radioHeight; } @@ -258,8 +263,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())