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 » How to prevent CExtResizableDialog from closing Collapse All
Subject Author Date
Chris Thomas May 10, 2005 - 8:45 AM

How can I prevent the user from closing/hiding my dialog via the window X button? (my dialog is derived from CExtResizableDialog and hosted in a docking bar). Or if that is not possible, is there a way to get a notification of that event? Thanks!

Technical Support May 11, 2005 - 10:20 AM

The "X"-button in the caption of a resizable control bar is an instance of the CExtBarNcAreaButtonClose class. You can get your control bars using your own button class in whcih you need to catch the click event and invoke parent’s method or do nothing. Create a CExtControlBar-derived class and override the CExtControlBar::OnNcAreaButtonsReinitialize() virtual method like as follows:

void C_YOUR_ControlBar::OnNcAreaButtonsReinitialize()
{
    ASSERT_VALID( this );
INT nCountOfNcButtons = NcButtons_GetCount();
    if( nCountOfNcButtons > 0 )
        return;
    NcButtons_Add( new C_YOUR_BarNcAreaButtonClose(this) );
#if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
    NcButtons_Add( new CExtBarNcAreaButtonAutoHide(this) );
#endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
    NcButtons_Add( new CExtBarNcAreaButtonMenu(this) );
}
The C_YOUR_BarNcAreaButtonClose class should be derived from CExtBarNcAreaButtonClose in which you need to override the CExtBarNcAreaButtonClose::OnNcAreaClicked() virtual method:
bool CExtBarNcAreaButtonClose::OnNcAreaClicked( CPoint point )
{
    ASSERT_VALID( this );
    if( ! m_rc.PtInRect(point) )
        return false;
    if( _CLICK_IS_DISABLED_ )
        return true; // eat click event
    return CExtBarNcAreaButtonClose::OnNcAreaClicked( point );
}

Chris Thomas May 13, 2005 - 8:54 AM

thanks!