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 » CExtControlBar close event Collapse All
Subject Author Date
Marat Garafutdinov Mar 3, 2004 - 5:08 PM

How can i get a notification from CExtControlBar when it’s close button (x in the top-right corner of the window) is clicked ?

Technical Support Mar 4, 2004 - 8:09 AM

Dear Marat,

Any button inside the non-client area of the control bar is not a window. Such buttons are instantiated from the CExtBarNcAreaButton class and provided with no notification messages.
You can replace the default implementation of these buttons with your own and handle button click events in the CExtBarNcAreaButton::OnNcAreaClicked().

First, derive a new class from CExtControlBar and override this method:

void CExtControlBar::OnNcAreaButtonsReinitialize()
{
    INT nCountOfNcButtons = NcButtons_GetCount();
    if( nCountOfNcButtons > 0 )
        return;
    NcButtons_Add( new CExtBarNcAreaButtonClose(this) );
#if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
    NcButtons_Add( new CExtBarNcAreaButtonAutoHide(this) );
#endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
    // NcButtons_Add( new CExtBarNcAreaButtonExpand(this) );
    NcButtons_Add( new CExtBarNcAreaButtonMenu(this) );
}
In it, you should replace the line:
NcButtons_Add( new CExtBarNcAreaButtonClose(this) );
with
NcButtons_Add( new CMyOwnImplOfNcAreaButtonClose(this) );
Second, derive CMyOwnImplOfNcAreaButtonClose from CExtBarNcAreaButtonClose and override the OnNcAreaClicked() method so you may catch mouse-click events.