+ wxRadioBox * const radiobox = wxRadioBox::GetFromRadioButtonHWND(hwnd);
+ wxCHECK_MSG( radiobox, 0, wxT("Should have the associated radio box") );
+
+ switch ( message )
+ {
+ case WM_GETDLGCODE:
+ // we must tell IsDialogMessage()/our kbd processing code that we
+ // want to process arrows ourselves because neither of them is
+ // smart enough to handle arrows properly for us
+ {
+ long lDlgCode = ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn, hwnd,
+ message, wParam, lParam);
+
+ return lDlgCode | DLGC_WANTARROWS;
+ }
+
+ case WM_KEYDOWN:
+ {
+ bool processed = true;
+
+ wxDirection dir;
+ switch ( wParam )
+ {
+ case VK_UP:
+ dir = wxUP;
+ break;
+
+ case VK_LEFT:
+ dir = wxLEFT;
+ break;
+
+ case VK_DOWN:
+ dir = wxDOWN;
+ break;
+
+ case VK_RIGHT:
+ dir = wxRIGHT;
+ break;
+
+ default:
+ processed = false;
+
+ // just to suppress the compiler warning
+ dir = wxALL;
+ }
+
+ if ( processed )
+ {
+ int selOld = radiobox->GetSelection();
+ int selNew = radiobox->GetNextItem
+ (
+ selOld,
+ dir,
+ radiobox->GetWindowStyle()
+ );
+
+ if ( selNew != selOld )
+ {
+ radiobox->SetSelection(selNew);
+ radiobox->SetFocus();
+
+ // emulate the button click
+ radiobox->SendNotificationEvent();
+
+ return 0;
+ }
+ }
+ }
+ break;
+
+ case WM_SETFOCUS:
+ case WM_KILLFOCUS:
+ {
+ // if we don't do this, no focus events are generated for the
+ // radiobox and, besides, we need to notify the parent about
+ // the focus change, otherwise the focus handling logic in
+ // wxControlContainer doesn't work
+ if ( message == WM_SETFOCUS )
+ radiobox->HandleSetFocus((WXHWND)wParam);
+ else
+ radiobox->HandleKillFocus((WXHWND)wParam);
+ }
+ break;
+
+#ifndef __WXWINCE__
+ case WM_HELP:
+ {
+ bool processed = false;
+
+ wxEvtHandler * const handler = radiobox->GetEventHandler();
+
+ HELPINFO* info = (HELPINFO*) lParam;
+ if ( info->iContextType == HELPINFO_WINDOW )
+ {
+ for ( wxWindow* subjectOfHelp = radiobox;
+ subjectOfHelp;
+ subjectOfHelp = subjectOfHelp->GetParent() )
+ {
+ wxHelpEvent helpEvent(wxEVT_HELP,
+ subjectOfHelp->GetId(),
+ wxPoint(info->MousePos.x,
+ info->MousePos.y));
+ helpEvent.SetEventObject(radiobox);
+ if ( handler->ProcessEvent(helpEvent) )
+ {
+ processed = true;
+ break;
+ }
+ }
+ }
+ else if (info->iContextType == HELPINFO_MENUITEM)
+ {
+ wxHelpEvent helpEvent(wxEVT_HELP, info->iCtrlId);
+ helpEvent.SetEventObject(radiobox);
+ processed = handler->ProcessEvent(helpEvent);
+ }
+
+ if ( processed )
+ return 0;
+ }
+ break;
+#endif // !__WXWINCE__
+ }
+
+ return ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn, hwnd, message, wParam, lParam);
+}