+#endif // __WXWINCE__
+
+// ---------------------------------------------------------------------------
+// window proc for radio buttons
+// ---------------------------------------------------------------------------
+
+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 ( 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;
+
+#ifndef __WXWINCE__
+ case WM_HELP:
+ {
+ wxRadioBox *radiobox = (wxRadioBox *)wxGetWindowUserData(hwnd);
+
+ wxCHECK_MSG( radiobox, 0, wxT("radio button without radio box?") );
+
+ 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);
+}