+// ---------------------------------------------------------------------------
+// window proc for radio buttons
+// ---------------------------------------------------------------------------
+
+#ifdef __WIN32__
+
+LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
+ UINT msg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ bool processed = FALSE;
+ if ( msg == WM_KEYDOWN
+#if wxUSE_TOOLTIPS
+ || msg == WM_NOTIFY
+#endif // wxUSE_TOOLTIPS
+ )
+ {
+ wxRadioBox *radiobox = (wxRadioBox *)::GetWindowLong(hwnd, GWL_USERDATA);
+
+ wxCHECK_MSG( radiobox, 0, wxT("radio button without radio box?") );
+
+#if wxUSE_TOOLTIPS
+ if ( msg == WM_NOTIFY )
+ {
+ NMHDR* hdr = (NMHDR *)lParam;
+ if ( (int)hdr->code == TTN_NEEDTEXT )
+ {
+ wxToolTip *tt = radiobox->GetToolTip();
+ if ( tt )
+ {
+ TOOLTIPTEXT *ttt = (TOOLTIPTEXT *)lParam;
+ ttt->lpszText = (wxChar *)tt->GetTip().c_str();
+
+ processed = TRUE;
+ }
+ }
+ }
+ else // msg == WM_KEYDOWN
+#endif // wxUSE_TOOLTIPS
+ {
+ processed = TRUE;
+
+ 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();
+ }
+ }
+ }
+ }
+
+ if ( processed )
+ return 0;
+
+ return ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn, hwnd, msg, wParam, lParam);
+}
+
+#endif // __WIN32__
+