+ // No GWL_USERDATA in Win16, so omit this subclassing.
+ ::SetWindowLong(hwndBtn, GWL_WNDPROC, (long)wxRadioBtnWndProc);
+ ::SetWindowLong(hwndBtn, GWL_USERDATA, (long)this);
+#endif // __WIN32__
+}
+
+void wxRadioBox::SendNotificationEvent()
+{
+ wxCommandEvent event(wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId);
+ event.SetInt( m_selectedButton );
+ event.SetString( GetString(m_selectedButton) );
+ event.SetEventObject( this );
+ ProcessCommand(event);
+}
+
+// ---------------------------------------------------------------------------
+// window proc for radio buttons
+// ---------------------------------------------------------------------------
+
+#ifdef __WIN32__
+
+LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
+ UINT msg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ bool processed = TRUE;
+ if ( msg != WM_KEYDOWN )
+ processed = FALSE;
+
+ if ( processed )
+ {
+ wxRadioBox *radiobox = (wxRadioBox *)::GetWindowLong(hwnd, GWL_USERDATA);
+
+ wxCHECK_MSG( radiobox, 0, _T("radio button without radio box?") );
+
+ int sel = radiobox->GetSelection();
+
+ switch ( wParam )
+ {
+ case VK_UP:
+ sel--;
+ break;
+
+ case VK_LEFT:
+ sel -= radiobox->GetNumVer();
+ break;
+
+ case VK_DOWN:
+ sel++;
+ break;
+
+ case VK_RIGHT:
+ sel += radiobox->GetNumVer();
+ break;
+
+ case VK_TAB:
+ {
+ wxNavigationKeyEvent event;
+ event.SetDirection(!(::GetKeyState(VK_SHIFT) & 0x100));
+ event.SetWindowChange(FALSE);
+ event.SetEventObject(radiobox);
+
+ if ( radiobox->GetEventHandler()->ProcessEvent(event) )
+ return 0;
+ }
+ // fall through
+
+ default:
+ processed = FALSE;
+ }
+
+ if ( processed )
+ {
+ if ( sel >= 0 && sel < radiobox->Number() )
+ {
+ radiobox->SetSelection(sel);
+
+ // emulate the button click
+ radiobox->SendNotificationEvent();
+ }
+ }