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 General Discussion » The problem to changing edit control focus by tab key at tab containers. Collapse All
Subject Author Date
Seung Cheol Lee Feb 2, 2009 - 10:49 PM

At the tab containers of prof-uis controls sample, I found the probem.

I made the edit controls to the dialog of tab contaners like the prof-uis controls sample.

I would change the focus of edit control by tab key.

At prof-uis 2.83, the string in edit control was selected all when the focus of edit control was changed.

But the string in edit control was not selected all somtimes at prof-uis 2.84

My application operated well at 2.83, but did not operate at 2.84 about above problem.

Could you check the probem.


Compile environment is release.

And character set is unicode.

OS is vista korean.

IDE is vs2005.

Technical Support Feb 3, 2009 - 12:30 PM

Thank you for reporting this issue. To fix it, please update the source code for the following method:

BOOL CExtResizableDialog::PreTranslateMessage(MSG* pMsg) 
{
            if(                     WM_KEYFIRST <= pMsg->message
                        &&        pMsg->message <= WM_KEYLAST
                        &&        GetSafeHwnd() != NULL
                        &&        ( pMsg->hwnd == m_hWnd || ::IsChild( m_hWnd, pMsg->hwnd ) )
                        &&        (GetStyle()&(WS_VISIBLE|WS_DISABLED)) == WS_VISIBLE
                        )
            { // pre translating keyboard input (if enabled/visible dialog)
                        if( pMsg->wParam == VK_TAB )
                        {
                                    if( m_bAllowLongFocusJumpFix )
                                    {
                                                if( pMsg->message == WM_KEYDOWN )
                                                {
                                                            HWND hWnd = ::GetFocus();
                                                            if( hWnd != NULL )
                                                            {
                                                                        bool bWantsTab = ( ( ::SendMessage( hWnd, WM_GETDLGCODE, VK_TAB, 0 ) & DLGC_WANTTAB ) != 0 ) ? true : false;
                                                                        if( bWantsTab )
                                                                        {
                                                                                    CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
                                                                                    if(                     pWnd != NULL
                                                                                                &&        (           pWnd->IsKindOf( RUNTIME_CLASS(CDialog) )
#if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
                                                                                                            ||           pWnd->IsKindOf( RUNTIME_CLASS(CExtTabPageContainerWnd) )
#endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
                                                                                                            )
                                                                                                )
                                                                                                bWantsTab = false;
                                                                        } // if( bWantsTab )
                                                                        if( ! bWantsTab )
                                                                        {
                                                                                    HWND hWndMain = m_hWnd;
                                                                                    if( ( __EXT_MFC_GetWindowLong( hWndMain, GWL_STYLE ) & WS_CHILD ) != 0 )
                                                                                                hWndMain = ::GetParent( m_hWnd );
                                                                                    for( ; ( __EXT_MFC_GetWindowLong( hWndMain, GWL_STYLE ) & WS_CHILD ) != 0 ; )
                                                                                                hWndMain = ::GetParent( hWndMain );
                                                                                    if( hWndMain != NULL )
                                                                                    {
                                                                                                BOOL bPrevious = CExtPopupMenuWnd::IsKeyPressed( VK_SHIFT );
                                                                                                hWnd = stat_GetNextItemZ( hWndMain, m_hWnd, hWnd, bPrevious );
                                                                                                //hWnd = ::GetNextDlgTabItem( m_hWnd, hWnd, CExtPopupMenuWnd::IsKeyPressed( VK_SHIFT ) );
                                                                                                if( hWnd != NULL )
                                                                                                {
                                                                                                            //CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
                                                                                                            g_bProcessingLongFocusJump = true;
                                                                                                            g_bProcessingLongFocusJumpToPrevDir = bPrevious ? true : false;
                                                                                                            ::SetFocus( hWnd );
                                                                                                            if( ::SendMessage( hWnd, WM_GETDLGCODE, WPARAM(VK_TAB), LPARAM(pMsg) ) )
                                                                                                                        ::SendMessage( hWnd, EM_SETSEL, WPARAM(0L), LPARAM(-1L) );
                                                                                                            g_bProcessingLongFocusJump = false;
                                                                                                            //pWnd;
                                                                                                }
                                                                                    }
                                                                        } // if( ! bWantsTab )
                                                            } // if( hWnd != NULL )
                                                } // if( pMsg->message == WM_KEYDOWN )
                                                return TRUE;
                                    } // if( m_bAllowLongFocusJumpFix )
                        } // if( pMsg->wParam == VK_TAB )
                        else
                        {
                                    if( (GetStyle()&(WS_VISIBLE|WS_CHILD)) == (WS_VISIBLE|WS_CHILD) )
                                    { // if child/visible dialog
                                                HWND hWndParent = ::GetParent( m_hWnd );
                                                CWnd * pWndParentPermanent = CWnd::FromHandlePermanent( hWndParent );
                                                if(                     pWndParentPermanent != NULL
                                                            &&        (           pWndParentPermanent->IsKindOf( RUNTIME_CLASS(CExtControlBar) )
#if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
                                                                        ||           pWndParentPermanent->IsKindOf( RUNTIME_CLASS(CExtDynAutoHideSlider) )
#endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
                                                                        )
                                                            &&        pWndParentPermanent->PreTranslateMessage(pMsg)
                                                            )
                                                            return TRUE;
                                    } // if child/visible dialog
                        } // else from if( pMsg->wParam == VK_TAB )

                        HWND hWndFocus = ::GetFocus();
                        if(                     hWndFocus != NULL
                                    &&        ::GetParent( hWndFocus ) == m_hWnd
                                    //&&      ( ::SendMessage( hWndFocus, WM_GETDLGCODE, 0L, 0L ) & (DLGC_WANTCHARS|DLGC_WANTALLKEYS) == 0 )
                                    )
                        {
                                    bool bProcessKey = false;
                                    BOOL bAlt = HIWORD(pMsg->lParam) & KF_ALTDOWN;
                                    LRESULT lRDC = ::SendMessage( hWndFocus, WM_GETDLGCODE, pMsg->wParam, 0L );
                                    if(                     ( lRDC & DLGC_WANTALLKEYS ) == 0
                                                &&        (           ( lRDC & DLGC_WANTCHARS ) == 0
                                                            ||           bAlt
                                                            )
                                                )
                                    {
                                                bProcessKey = true;
                                    }
                                    if( bProcessKey )
                                    {
                                                //BOOL bKeyUp = ( pMsg->message == WM_KEYUP || pMsg->message == WM_SYSKEYUP) ? TRUE : FALSE;
                                                BOOL bCtrl = GetKeyState(VK_CONTROL) & 0x80000000;
                                                BOOL bShift = GetKeyState(VK_SHIFT) & 0x80000000;
                                                if( ! ( bCtrl || bShift ) )
                                                {
                                                            TCHAR vkTCHAR = (TCHAR)pMsg->wParam;
                                                            BYTE lpKeyState[256];
                                                            ::GetKeyboardState( lpKeyState );
                                                            UINT wScanCode = ::MapVirtualKey( vkTCHAR, 0 );
                                                            HKL hKeyboardLayout =
                                                                        ::GetKeyboardLayout(
                                                                                    ( ::AfxGetThread() ) -> m_nThreadID
                                                                                    );
#if (defined _UNICODE)
                                                            TCHAR szChar[2] = { _T(’\0’), _T(’\0’) };
                                                            ::ToUnicodeEx(
                                                                        vkTCHAR,
                                                                        wScanCode,
                                                                        lpKeyState,
                                                                        szChar, 1,
                                                                        1,
                                                                        hKeyboardLayout
                                                                        );
#else
                                                            WORD nMapped = 0;
                                                            ::ToAsciiEx(
                                                                        vkTCHAR,
                                                                        wScanCode,
                                                                        lpKeyState,
                                                                        &nMapped,
                                                                        1,
                                                                        hKeyboardLayout
                                                                        );
                                                            TCHAR szChar[2] = { (TCHAR)nMapped, _T(’\0’) };
#endif
                                                            ::CharUpper( szChar );
                                                            if( szChar[0] != 0 )
                                                            {
                                                                        HWND hWnd = ::GetWindow( m_hWnd, GW_CHILD );
                                                                        for( ; hWnd != NULL; hWnd = ::GetWindow( hWnd, GW_HWNDNEXT ) )
                                                                        {
                                                                                    CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
                                                                                    if( pWnd == NULL )
                                                                                                continue;
                                                                                    if( (pWnd->GetStyle()&(WS_VISIBLE|WS_DISABLED)) != WS_VISIBLE )
                                                                                                continue;
                                                                                    CExtButton * pExtButton = DYNAMIC_DOWNCAST( CExtButton, pWnd );
                                                                                    if( pExtButton == NULL )
                                                                                                continue;
                                                                                    if(                     pExtButton->m_bQuickActivationEnabled
                                                                                                &&        pExtButton->_QuickActivationCheck( DWORD(vkTCHAR) )
                                                                                                )
                                                                                    {
                                                                                                if(                     pMsg->message == WM_KEYDOWN
                                                                                                            ||           pMsg->message == WM_SYSKEYDOWN
                                                                                                            )
                                                                                                {
                                                                                                            if( hWndFocus != pExtButton->m_hWnd )
                                                                                                                        pExtButton->SetFocus();
                                                                                                }
                                                                                                if(                     pMsg->message == WM_KEYUP
                                                                                                            ||           pMsg->message == WM_SYSKEYUP
                                                                                                            )
                                                                                                {
                                                                                                            if( pExtButton->PreTranslateMessage( pMsg ) )
                                                                                                                        return TRUE;
                                                                                                }
                                                                                                //break;
                                                                                                return TRUE;
                                                                                    }
                                                                        }
                                                            }
                                                } // if( ! ( bCtrl || bShift ) )
                                    } // if( bProcessKey )
                        } // if( hWndFocus != NULL && ::GetParent( hWndFocus ) == m_hWnd ...
            } // pre translating keyboard input (if enabled/visible dialog)

            if(                     ( GetStyle() & WS_VISIBLE ) != 0
                        &&        CExtControlBar::DoCustomModePreTranslateMessage( this, pMsg )
                        )
                        return TRUE;
            return CExtWA < CExtWS < __BASEOF_CExtResizableDialog__ > >::PreTranslateMessage(pMsg);
}