Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » ALT GR key; special characters; StateSetCombo; ComboBox; Collapse All
Subject Author Date
Stephan Finkler Jan 27, 2006 - 2:24 AM

I’ve got a CmdItem in the toolbar with a combo state
(like StyleEditor sample ID_SE_FONT_LIST).

If I press the ALT GR key (German Keyboard)
the combobox looses the focus. So it is impossible to insert
special characters e.g. Euro symbol

Any idea?

Technical Support Jan 27, 2006 - 10:31 AM

There are two things that need to be discussed about the in-place active editor in the built in combo box button. Both can be demonstrated with the StyleEditor sample application.

1) We cannot confirm that there is a problem when pressing the left or right ALT key in the editor. It works exactly like in MS Office applications. The WM_SYSKEYDOWN with VK_MENU key code specified does not destroy the editor. The corresponding WM_SYSKEYUP activates the menu bar.

2) The in-place editor does not allow you to type characters using the code input as you did. This bug can be fixed by updating the source code for the CExtBarTextFieldButton::CInPlaceEditWnd::PreTranslateMessage() and CExtBarTextFieldButton::CInPlaceEditWnd::WindowProc() methods in ExtPopupCtrlMenu.cpp file:

BOOL CExtBarTextFieldButton::CInPlaceEditWnd::PreTranslateMessage( MSG * pMsg )
{
    ASSERT_VALID( m_pBar );
    if( ! _IsValidState() )
        return CEdit::PreTranslateMessage( pMsg );
    if( !m_bCanceling )
    {
        if( pMsg->message == WM_KEYDOWN )
        {
            bool bAlt =
                ( (::GetAsyncKeyState(VK_MENU)&0x8000) != 0 )
                    ? true : false;
            if( !bAlt )
            {
                bool bCtrl =
                    ( (::GetAsyncKeyState(VK_CONTROL)&0x8000) != 0 )
                        ? true : false;
                bool bShift =
                    ( (::GetAsyncKeyState(VK_SHIFT)&0x8000) != 0 )
                        ? true : false;
                if(        bCtrl
                    &&    (!bShift)
                    &&    (    int(pMsg->wParam) == VK_INSERT
                        ||    int(pMsg->wParam) == int( _T(’C’) )
                        )
                    )
                {
                    SendMessage( WM_COPY, 0, 0 );
                    return TRUE;
                } 
                if(        ( bCtrl && (!bShift) && int(pMsg->wParam) == int( _T(’V’) ) )
                    ||    ( (!bCtrl) && bShift && int(pMsg->wParam) == VK_INSERT )
                    )
                {
                    SendMessage( WM_PASTE, 0, 0 );
                    return TRUE;
                } 
                if(        ( bCtrl && (!bShift) && int(pMsg->wParam) == int( _T(’X’) ) )
                    ||    ( (!bCtrl) && bShift && int(pMsg->wParam) == VK_DELETE )
                    )
                {
                    SendMessage( WM_CUT, 0, 0 );
                    return TRUE;
                } 
                if(    bCtrl && (!bShift) && int(pMsg->wParam) == int( _T(’A’) ) ) 
                {
                    SetSel( 0, -1 );
                    return TRUE;
                }
            } // if( !bAlt )
        } // if( pMsg->message == WM_KEYDOWN )
        else if(
                pMsg->message == WM_LBUTTONDOWN
            ||    pMsg->message == WM_MBUTTONDOWN
            ||    pMsg->message == WM_RBUTTONDOWN
            )
        {
            if( pMsg->hwnd != m_hWnd )
            {
                m_bCanceling = true;
                PostMessage( (WM_USER+0x666) );
            }
        }
    } // if( !m_bCanceling )
    
    // HASH Added START
    // (Allows single key accelerators)
    if(        (    pMsg->message == WM_KEYDOWN
            ||    pMsg->message == WM_CHAR
            ||    pMsg->message == WM_SYSKEYDOWN
            ||    pMsg->message == WM_SYSKEYUP
            )
        &&    pMsg->hwnd == m_hWnd
        )
    {
        ::TranslateMessage( pMsg );
        ::DispatchMessage( pMsg );
        return TRUE;
    }
    // HASH Added END
    
    return CEdit::PreTranslateMessage( pMsg );
}
 
LRESULT CExtBarTextFieldButton::CInPlaceEditWnd::WindowProc(
    UINT message,
    WPARAM wParam,
    LPARAM lParam
    )
{
    ASSERT_VALID( m_pBar );
    if( ! _IsValidState() )
        return CEdit::WindowProc( message, wParam, lParam );
    if( m_pCbWndProc != NULL )
    {
        LRESULT lResult = 0L;
        if( m_pCbWndProc(
                lResult,
                message,
                wParam,
                lParam,
                *this,
                m_pCbCookie
                )
            )
            return lResult;
    } // if( m_pCbWndProc != NULL )
    if( !m_bCanceling )
    {
        if(        CExtPopupMenuWnd::IsMenuTracking()
            ||    CExtControlBar::_DraggingGetBar() != NULL
            )
        {
            m_bCanceling = true;
            PostMessage( (WM_USER+0x666) );
        }
    }
    if( message == (WM_USER+0x666) )
    {
        GetBarTextFieldButton()->OnInplaceControlSessionCancel();
        return 0;
    }
    if( message == WM_NCCALCSIZE )
    {
        NCCALCSIZE_PARAMS * pNCCSP =
            reinterpret_cast < NCCALCSIZE_PARAMS * > ( lParam );
        ASSERT( pNCCSP != NULL );
        CRect rcInBarWnd( pNCCSP->rgrc[0] );
        rcInBarWnd.DeflateRect( 2, 2, 0, 2 );
        ::CopyRect( &(pNCCSP->rgrc[0]), rcInBarWnd );
        return 0;
    } // if( message == WM_NCCALCSIZE )
    if( message == WM_NCPAINT )
    {
        CRect rcInBarWnd, rcInBarClient;
        GetWindowRect( &rcInBarWnd );
        GetClientRect( &rcInBarClient );
        ClientToScreen( &rcInBarClient );
        if( rcInBarWnd == rcInBarClient )
            return 0;
        CPoint ptDevOffset = -rcInBarWnd.TopLeft();
        rcInBarWnd.OffsetRect( ptDevOffset );
        rcInBarClient.OffsetRect( ptDevOffset );
        CWindowDC dc( this );
        ASSERT( dc.GetSafeHdc() != NULL );
        dc.ExcludeClipRect( &rcInBarClient );
        dc.FillSolidRect(
            rcInBarWnd,
            m_pBar->PmBridge_GetPM()->GetColor( COLOR_WINDOW, this )
            );
        return 0;
    } // if( message == WM_NCPAINT )
    if( message == WM_GETDLGCODE )
        return DLGC_WANTALLKEYS|DLGC_WANTCHARS|DLGC_WANTTAB|DLGC_HASSETSEL;
    if(        message == WM_RBUTTONDOWN
        ||    message == WM_RBUTTONUP
        ||    message == WM_RBUTTONDBLCLK
        ||    message == WM_CONTEXTMENU
        )
        return 0;
    
    if( message == WM_KEYDOWN )
    {
        if(        int(wParam) == VK_MENU
            ||    int(wParam) == VK_ESCAPE
            )
        {
            GetBarTextFieldButton()->OnInplaceControlSessionCancel();
            return 0;
        }
        if(        int(wParam) == VK_DOWN
            ||    int(wParam) == VK_UP
            ||    int(wParam) == VK_F4
            )
        {
            CExtBarTextFieldButton * pTextFieldTBB =
                GetBarTextFieldButton();
            if( pTextFieldTBB->IsComboTextField() )
            {
                pTextFieldTBB->OnInplaceControlSessionEnd();
                pTextFieldTBB->OnTrackPopup( CPoint(0,0), true, false );
                return 0;
            }
        }
 
        if( int(wParam) == VK_RETURN )
        {
            ASSERT( m_pStr != NULL );
            CExtSafeString sText;
            int nTextLength = GetWindowTextLength();
            if( nTextLength > 0 )
            {
                GetWindowText( sText.GetBuffer(nTextLength+2), nTextLength+1 );
                sText.ReleaseBuffer();
            }
            if( m_pCbVerifyTextInput != NULL )
            {
                if(    m_pCbVerifyTextInput(
                        *this,
                        m_pCbCookie,
                        sText.IsEmpty() ? _T("") : sText,
                        sText.IsEmpty() ? _T("") : sText
                        )
                    )
                    *m_pStr = sText;
            } // if( m_pCbVerifyTextInput != NULL )
            else
                *m_pStr = sText;
            GetBarTextFieldButton()->OnInplaceControlSessionEnd();
            return 0;
        }
        bool bAlt =
            ( (::GetAsyncKeyState(VK_MENU)&0x8000) != 0 )
                ? true : false;
        if( bAlt )
        {
            GetBarTextFieldButton()->OnInplaceControlSessionCancel();
            return 0;
        }
 
        ASSERT( m_pStr != NULL );
        CString sTextOld;
        GetWindowText( sTextOld );
        DWORD dwSelSaved = CEdit::GetSel();
        CEdit::SetRedraw( FALSE );
        LRESULT lResult = CEdit::WindowProc( message, wParam, lParam );
        CString sTextNew;
        GetWindowText( sTextNew );
        if( m_pCbVerifyTextInput != NULL )
        {
            if(    m_pCbVerifyTextInput(
                    *this,
                    m_pCbCookie,
                    sTextOld.IsEmpty() ? _T("") : (LPCTSTR)sTextOld,
                    sTextNew.IsEmpty() ? _T("") : (LPCTSTR)sTextNew
                    )
                )
                *m_pStr = sTextNew;
            else
            {
                CEdit::SetSel( 0, -1 );
                CEdit::ReplaceSel( sTextOld );
                CEdit::SetSel( dwSelSaved );
            }
        } // if( m_pCbVerifyTextInput != NULL )
        else
            *m_pStr = sTextNew;
        CEdit::SetRedraw( TRUE );
        Invalidate();
        UpdateWindow();
        
        return lResult;
    } // if( message == WM_KEYDOWN )
    else if( message == WM_CHAR )
    {
        ASSERT( m_pStr != NULL );
        CString sTextOld;
        GetWindowText( sTextOld );
        DWORD dwSelSaved = CEdit::GetSel();
        CEdit::SetRedraw( FALSE );
        LRESULT lResult = CEdit::WindowProc( message, wParam, lParam );
        CString sTextNew;
        GetWindowText( sTextNew );
        if( m_pCbVerifyTextInput != NULL )
        {
            if(    m_pCbVerifyTextInput(
                    *this,
                    m_pCbCookie,
                    sTextOld.IsEmpty() ? _T("") : (LPCTSTR)sTextOld,
                    sTextNew.IsEmpty() ? _T("") : (LPCTSTR)sTextNew
                    )
                )
                *m_pStr = sTextNew;
            else
            {
                CEdit::SetSel( 0, -1 );
                CEdit::ReplaceSel( sTextOld );
                CEdit::SetSel( dwSelSaved );
            }
        } // if( m_pCbVerifyTextInput != NULL )
        else
            *m_pStr = sTextNew;
        CEdit::SetRedraw( TRUE );
        Invalidate();
        UpdateWindow();
 
        return lResult;
    } // else if( message == WM_CHAR )
    else if( message == WM_KILLFOCUS || message == WM_CANCELMODE )
    {
        GetBarTextFieldButton()->OnInplaceControlSessionCancel();
        return 0;
    } // else if( message == WM_KILLFOCUS || message == WM_CANCELMODE )
 
    return CEdit::WindowProc( message, wParam, lParam );
}