示例#1
0
bool wxComboBox::MSWProcessEditMsg(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam)
{
    switch ( msg )
    {
        case WM_CHAR:
            // for compatibility with wxTextCtrl, generate a special message
            // when Enter is pressed
            switch ( wParam )
            {
                case VK_RETURN:
                    {
                        if (SendMessage(GetHwnd(), CB_GETDROPPEDSTATE, 0, 0))
                            return false;

                        wxCommandEvent event(wxEVT_TEXT_ENTER, m_windowId);

                        const int sel = GetSelection();
                        event.SetInt(sel);
                        event.SetString(GetValue());
                        InitCommandEventWithItems(event, sel);

                        if ( ProcessCommand(event) )
                        {
                            // don't let the event through to the native control
                            // because it doesn't need it and may generate an annoying
                            // beep if it gets it
                            return true;
                        }
                    }
                    break;

                case VK_TAB:
                    // If we have wxTE_PROCESS_ENTER style, we get all char
                    // events, including those for TAB which are usually used
                    // for keyboard navigation, but we should not process them
                    // unless we also have wxTE_PROCESS_TAB style.
                    if ( !HasFlag(wxTE_PROCESS_TAB) )
                    {
                        int flags = 0;
                        if ( !wxIsShiftDown() )
                            flags |= wxNavigationKeyEvent::IsForward;
                        if ( wxIsCtrlDown() )
                            flags |= wxNavigationKeyEvent::WinChange;
                        if ( Navigate(flags) )
                            return true;
                    }
                    break;
            }
    }

    if ( ShouldForwardFromEditToCombo(msg) )
    {
        // For all the messages forward from the edit control the
        // result is not used.
        WXLRESULT result;
        return MSWHandleMessage(&result, msg, wParam, lParam);
    }

    return false;
}
示例#2
0
bool wxComboBox::MSWProcessEditMsg(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam)
{
    switch ( msg )
    {
        case WM_CHAR:
            // for compatibility with wxTextCtrl, generate a special message
            // when Enter is pressed
            if ( wParam == VK_RETURN )
            {
                if (SendMessage(GetHwnd(), CB_GETDROPPEDSTATE, 0, 0))
                    return false;

                wxCommandEvent event(wxEVT_TEXT_ENTER, m_windowId);

                const int sel = GetSelection();
                event.SetInt(sel);
                event.SetString(GetValue());
                InitCommandEventWithItems(event, sel);

                if ( ProcessCommand(event) )
                {
                    // don't let the event through to the native control
                    // because it doesn't need it and may generate an annoying
                    // beep if it gets it
                    return true;
                }
            }
            // fall through, WM_CHAR is one of the message we should forward.

        default:
            if ( ShouldForwardFromEditToCombo(msg) )
            {
                // For all the messages forward from the edit control the
                // result is not used.
                WXLRESULT result;
                return MSWHandleMessage(&result, msg, wParam, lParam);
            }
    }

    return false;
}
示例#3
0
LRESULT APIENTRY _EXPORT wxComboEditWndProc(HWND hWnd,
                                            UINT message,
                                            WPARAM wParam,
                                            LPARAM lParam)
{
    HWND hwndCombo = ::GetParent(hWnd);
    wxWindow *win = wxFindWinFromHandle((WXHWND)hwndCombo);

    if ( ShouldForwardFromEditToCombo(message) )
    {
        wxComboBox *combo = wxDynamicCast(win, wxComboBox);
        if ( !combo )
        {
            // we can get WM_KILLFOCUS while our parent is already half
            // destroyed and hence doesn't look like a combobx any
            // longer, check for it to avoid bogus assert failures
            if ( !win->IsBeingDeleted() )
            {
                wxFAIL_MSG( wxT("should have combo as parent") );
            }
        }
        else if ( combo->MSWProcessEditMsg(message, wParam, lParam) )
        {
            // handled by parent
            return 0;
        }
    }
    else if ( message == WM_GETDLGCODE )
    {
        wxCHECK_MSG( win, 0, wxT("should have a parent") );

        if ( win->GetWindowStyle() & wxTE_PROCESS_ENTER )
        {
            // need to return a custom dlg code or we'll never get it
            return DLGC_WANTMESSAGE;
        }
    }

    return ::CallWindowProc(CASTWNDPROC gs_wndprocEdit, hWnd, message, wParam, lParam);
}