+ 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;
+ }
+
+#if wxUSE_TOOLTIPS
+ case WM_NOTIFY:
+ {
+ NMHDR* hdr = (NMHDR *)lParam;
+ if ( hdr->code == TTN_NEEDTEXT )
+ {
+ wxRadioBox *
+ radiobox = (wxRadioBox *)wxGetWindowUserData(hwnd);
+
+ wxCHECK_MSG( radiobox, 0,
+ wxT("radio button without radio box?") );
+
+ wxToolTip *tooltip = radiobox->GetToolTip();
+ if ( tooltip )
+ {
+ TOOLTIPTEXT *ttt = (TOOLTIPTEXT *)lParam;
+ ttt->lpszText = (wxChar *)tooltip->GetTip().c_str();
+ }
+
+ // processed
+ return 0;
+ }
+ }
+ break;
+#endif // wxUSE_TOOLTIPS
+
+ case WM_KEYDOWN:
+ {
+ wxRadioBox *radiobox = (wxRadioBox *)wxGetWindowUserData(hwnd);
+
+ wxCHECK_MSG( radiobox, 0, wxT("radio button without radio box?") );
+
+ 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:
+ {
+ wxRadioBox *radiobox = (wxRadioBox *)wxGetWindowUserData(hwnd);
+
+ wxCHECK_MSG( radiobox, 0, wxT("radio button without radio box?") );
+
+ // 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;
+
+#ifdef __WIN32__
+ case WM_HELP:
+ {
+ wxRadioBox *radiobox = (wxRadioBox *)wxGetWindowUserData(hwnd);
+
+ wxCHECK_MSG( radiobox, 0, wxT("radio button without radio box?") );
+
+ bool processed = TRUE;
+
+ // HELPINFO doesn't seem to be supported on WinCE.
+#ifndef __WXWINCE__
+ HELPINFO* info = (HELPINFO*) lParam;
+ // Don't yet process menu help events, just windows
+ if (info->iContextType == HELPINFO_WINDOW)
+#endif
+ {
+ wxWindow* subjectOfHelp = radiobox;
+ bool eventProcessed = FALSE;
+ while (subjectOfHelp && !eventProcessed)
+ {
+ wxHelpEvent helpEvent(wxEVT_HELP, subjectOfHelp->GetId(),
+#ifdef __WXWINCE__
+ wxPoint(0, 0)
+#else
+ wxPoint(info->MousePos.x, info->MousePos.y)
+#endif
+ ) ; // info->iCtrlId);
+ helpEvent.SetEventObject(radiobox);
+ eventProcessed = radiobox->GetEventHandler()->ProcessEvent(helpEvent);
+
+ // Go up the window hierarchy until the event is handled (or not)
+ subjectOfHelp = subjectOfHelp->GetParent();
+ }
+ processed = eventProcessed;
+ }
+#ifndef __WXWINCE__
+ else if (info->iContextType == HELPINFO_MENUITEM)
+ {
+ wxHelpEvent helpEvent(wxEVT_HELP, info->iCtrlId) ;
+ helpEvent.SetEventObject(radiobox);
+ processed = radiobox->GetEventHandler()->ProcessEvent(helpEvent);
+ }
+ else
+ processed = FALSE;
+#endif
+ if (processed)
+ return 0;
+
+ break;
+ }
+#endif // __WIN32__
+ }
+
+ return ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn, hwnd, message, wParam, lParam);