LRESULT APIENTRY _EXPORT wxBuddyTextWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { wxSpinCtrl *spin = (wxSpinCtrl *)wxGetWindowUserData(hwnd); // forward some messages (mostly the key and focus ones) to the spin ctrl switch ( message ) { case WM_SETFOCUS: // if the focus comes from the spin control itself, don't set it // back to it -- we don't want to go into an infinite loop if ( (WXHWND)wParam == spin->GetHWND() ) break; //else: fall through case WM_KILLFOCUS: case WM_CHAR: case WM_DEADCHAR: case WM_KEYUP: case WM_KEYDOWN: #ifdef WM_HELP // we need to forward WM_HELP too to ensure that the context help // associated with wxSpinCtrl is shown when the text control part of it // is clicked with the "?" cursor case WM_HELP: #endif spin->MSWWindowProc(message, wParam, lParam); // The control may have been deleted at this point, so check. if ( !::IsWindow(hwnd) || wxGetWindowUserData(hwnd) != spin ) return 0; break; case WM_GETDLGCODE: if ( spin->HasFlag(wxTE_PROCESS_ENTER) ) { long dlgCode = ::CallWindowProc ( CASTWNDPROC spin->GetBuddyWndProc(), hwnd, message, wParam, lParam ); dlgCode |= DLGC_WANTMESSAGE; return dlgCode; } break; } return ::CallWindowProc(CASTWNDPROC spin->GetBuddyWndProc(), hwnd, message, wParam, lParam); }
LRESULT APIENTRY _EXPORT wxBuddyTextCtrlWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { wxTextCtrl *spin = (wxTextCtrl *)wxGetWindowUserData(hwnd); // forward some messages (the key and focus ones only so far) to // the spin ctrl switch ( message ) { case WM_SETFOCUS: // if the focus comes from the spin control itself, don't set it // back to it -- we don't want to go into an infinite loop if ( (WXHWND)wParam == spin->GetHWND() ) break; //else: fall through case WM_KILLFOCUS: case WM_CHAR: case WM_DEADCHAR: case WM_KEYUP: case WM_KEYDOWN: spin->MSWWindowProc(message, wParam, lParam); // The control may have been deleted at this point, so check. if ( !::IsWindow(hwnd) || wxGetWindowUserData(hwnd) != spin ) return 0; break; case WM_GETDLGCODE: // we want to get WXK_RETURN in order to generate the event for it return DLGC_WANTCHARS; } return ::CallWindowProc(CASTWNDPROC spin->GetBuddyWndProc(), hwnd, message, wParam, lParam); }
/* static */ wxSpinCtrl *wxSpinCtrl::GetSpinForTextCtrl(WXHWND hwndBuddy) { wxSpinCtrl *spin = (wxSpinCtrl *)wxGetWindowUserData((HWND)hwndBuddy); int i = ms_allSpins.Index(spin); if ( i == wxNOT_FOUND ) return NULL; // sanity check wxASSERT_MSG( spin->m_hwndBuddy == hwndBuddy, _T("wxSpinCtrl has incorrect buddy HWND!") ); return spin; }
wxChoice *wxChoice::GetChoiceForListBox(WXHWND hwndBuddy) { wxChoice *choice = (wxChoice *)wxGetWindowUserData((HWND)hwndBuddy); int i = ms_allChoiceSpins.Index(choice); if ( i == wxNOT_FOUND ) return NULL; // sanity check wxASSERT_MSG( choice->m_hwndBuddy == hwndBuddy, _T("wxChoice has incorrect buddy HWND!") ); return choice; }
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); }