+#ifdef __WIN32__
+
+LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
+ UINT message,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ 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 ( (int)hdr->code == TTN_NEEDTEXT )
+ {
+ wxRadioBox *radiobox = (wxRadioBox *)
+ ::GetWindowLong(hwnd, GWL_USERDATA);
+
+ 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 *)
+ ::GetWindowLong(hwnd, GWL_USERDATA);
+
+ wxCHECK_MSG( radiobox, 0, wxT("radio button without radio box?") );
+
+ bool processed = TRUE;
+
+ int selOld = radiobox->GetSelection();
+ int selNew = selOld;
+
+ switch ( wParam )
+ {
+ case VK_UP:
+ selNew--;
+ break;
+
+ case VK_LEFT:
+ selNew -= radiobox->GetNumVer();
+ break;
+
+ case VK_DOWN:
+ selNew++;
+ break;
+
+ case VK_RIGHT:
+ selNew += radiobox->GetNumVer();
+ break;
+
+ default:
+ processed = FALSE;
+ }
+
+ if ( processed )
+ {
+ // ensure that selNew is in range [0..num)
+ int num = radiobox->Number();
+ selNew += num;
+ selNew %= num;
+
+ if ( selNew != selOld )
+ {
+ radiobox->SetSelection(selNew);
+
+ // emulate the button click
+ radiobox->SendNotificationEvent();
+
+ return 0;
+ }
+ }
+ }