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 » Default button in dialog not working when radio button is active Collapse All
Subject Author Date
Krister Goodh Apr 6, 2010 - 7:43 AM

I have a dialog of type CExtNCW<CExtResizableDialog> containing some controlls and two buttons (one default button with IDOK).


The default button is not working (enter press have no effect) when the cursor is on a radio button (radio button selection can be modified with arrow keys). If any other controll is active, the default button is working.


This behaviour is the same in all dialogs in the program.


Is there a way around this?


 

Krister Goodh Apr 12, 2010 - 12:12 AM

Hello!


That solved this bug. Thanks.  I’m still waiting for input regarding the bug described in:


"Forums » Prof-UIS Tech Support » CExtPropertyGridCtrl assert when removing item that is edited "


The bugfix provided by you did not solve the problem entierly. Please note the line added by me containing pDP->m_pOuterDataProvider and where the result of that goes..


/J


 

Technical Support Apr 10, 2010 - 10:26 AM

We are sorry for the delay with this reply. Thank you for reporting this issue. To fix it, please update the source code for the following method:

BOOL CExtButton::PreTranslateMessage(MSG* pMsg) 
{
            if(                     (! CExtPopupMenuWnd::IsMenuTracking() )
                        &&        OnAdvancedPopupMenuTipWndGet() == NULL
                        )
            {
                        InitToolTip();
                        m_wndToolTip.RelayEvent( pMsg );
            }

            if(                     ( pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP )
                        &&        ( pMsg->wParam == VK_RETURN || pMsg->wParam == VK_SPACE )
                        )
            {
                        bool bEnabled = OnQueryWindowEnabledState();
                        if(                     bEnabled
                                    &&        IsWindowVisible()
                                    )
                        {
                                    if( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN )
                                    {
                                                HWND hWndFocus = ::GetFocus();
                                                if( hWndFocus != NULL && hWndFocus == m_hWnd )
                                                {
                                                            if( /*m_nButtonType == BS_RADIOBUTTON ||*/ m_nButtonType == BS_AUTORADIOBUTTON )
                                                                        return FALSE;
                                                            _OnClick( true, false );
                                                            return TRUE;
                                                }
                                                __EXT_MFC_LONG_PTR dwWndStyle = ::__EXT_MFC_GetWindowLong( m_hWnd, GWL_STYLE );
#ifdef BS_TYPEMASK
                                                ASSERT( BS_TYPEMASK == 0x0000000FL );
#endif
                                                __EXT_MFC_LONG_PTR dwWndType = ( dwWndStyle & 0x0000000FL );
                                                if(                     GetFocus() == this 
                                                            &&        dwWndType != BS_DEFPUSHBUTTON 
                                                            )
                                                {
                                                            HWND hWndParent = ::GetParent( m_hWnd ); 
                                                            HWND hWnd = ::GetWindow( hWndParent, GW_CHILD ); 
                                                            while( hWnd != NULL )  
                                                            {
                                                                        TCHAR szCompare[512] = _T("");
                                                                        ::GetClassName(
                                                                                    hWnd,
                                                                                    szCompare,
                                                                                    sizeof( szCompare )/sizeof( szCompare[0] )
                                                                                    );
                                                                        if( _tcsicmp( szCompare, _T("BUTTON") ) == 0 )
                                                                        {
                                                                                    bool bDefault = false;
                                                                                    CWnd * pWnd = CWnd::FromHandlePermanent( hWnd ); 
                                                                                    if(                     pWnd->GetSafeHwnd() != NULL 
                                                                                                &&        pWnd->IsKindOf( RUNTIME_CLASS( CExtButton ) ) 
                                                                                                )
                                                                                    {
                                                                                                CExtButton * pBtn = STATIC_DOWNCAST( CExtButton, pWnd );
                                                                                                ASSERT_VALID( pBtn );
                                                                                                bDefault = pBtn->GetDefault( false ) ? true : false;
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                                bDefault = ( ( ::__EXT_MFC_GetWindowLong( hWnd, GWL_STYLE ) & 0x0000000FL ) == BS_DEFPUSHBUTTON ) ? true : false;
                                                                                    }

                                                                                    if( bDefault )
                                                                                    {
                                                                                                int nDlgCtrlID = ::GetDlgCtrlID( hWnd );
                                                                                                ::SendMessage(
                                                                                                            hWndParent,
                                                                                                            WM_COMMAND,
                                                                                                            MAKEWPARAM( nDlgCtrlID, BN_CLICKED ),
                                                                                                            (LPARAM)hWnd
                                                                                                            );
                                                                                                return TRUE;                                                                             
                                                                                    }
                                                                        }

                                                                        hWnd = ::GetWindow( hWnd, GW_HWNDNEXT );  
                                                            }
                                                }
                                                _OnClick( true, false );
                                                return TRUE;
                                    }

                                    if(                     pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_SPACE 
                                                &&        (!m_bPushTracking)
                                                )
                                    {
                                                bool bAnimationLocked = AnimationClient_CacheGeneratorIsLocked();
                                                if( ! bAnimationLocked )
                                                {
                                                            AnimationClient_CacheGeneratorLock();
//                                                          if( AnimationClient_StateGet(true).IsEmpty() )
                                                                       AnimationClient_CacheNextStateMinInfo(
                                                                                    false,
                                                                                    __EAPT_BY_PRESSED_STATE_TURNED_ON
                                                                                    );
                                                }
                                                m_bPushed = m_bPushTracking = m_bKeyTracking = true;
                                                if( ! bAnimationLocked )
                                                {
                                                           AnimationClient_CacheNextStateMinInfo(
                                                                        true,
                                                                        __EAPT_BY_PRESSED_STATE_TURNED_ON
                                                                        );
                                                            AnimationClient_CacheGeneratorUnlock();
                                                }
                                                Invalidate();
                                                return TRUE;
                                    }

                                    if(         pMsg->message == WM_KEYUP && pMsg->wParam == VK_SPACE )
                                    {
                                                bool bAnimationLocked = AnimationClient_CacheGeneratorIsLocked();
                                                if( ! bAnimationLocked )
                                                {
                                                            AnimationClient_CacheGeneratorLock();
//                                                          if( AnimationClient_StateGet(true).IsEmpty() )
                                                                       AnimationClient_CacheNextStateMinInfo(
                                                                                    false,
                                                                                    __EAPT_BY_PRESSED_STATE_TURNED_OFF
                                                                                    );
                                                }
                                                m_bPushed = m_bPushTracking = m_bKeyTracking = m_bMouseOver = false;
                                                if( ! bAnimationLocked )
                                                {
                                                           AnimationClient_CacheNextStateMinInfo(
                                                                        true,
                                                                        __EAPT_BY_PRESSED_STATE_TURNED_OFF
                                                                        );
                                                            AnimationClient_CacheGeneratorUnlock();
                                                }
                                                _OnClick( true, false );
                                                return TRUE;
                                    }
                        }
                        return TRUE;
            }
            if(                     m_bQuickActivationEnabled
                        &&        (           pMsg->message == WM_KEYUP
                                    ||           pMsg->message == WM_SYSKEYUP
                                    )
                        )
            {
                        if( _QuickActivationCheck( DWORD(pMsg->wParam) ) )
                        {
                                    if( _QuickActivationHandle() )
                                                return TRUE;
                        }
            }

            return CButton::PreTranslateMessage(pMsg);
}