Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
4.67/5 (3 votes)
See more:
one floating CDockablePane(CDP). I want to capture the close event when use press 'x' button on the capture area to do something else. MSDN says that I can do it in OnPressCloseButton()
C#
virtual void OnPressCloseButton();
This function is called by the framework when user presses the close button on control bar's caption. Override it in a derived class to get notified about this event.


But it seems not work when CDP is floating, but not docked. When floating the CDP is in one mini frame wnd. The mini-frame wnd will handle this event as follows...

void CPaneFrameWnd::OnLButtonUp(UINT nFlags, CPoint point)
{
	m_bIsMoving = FALSE;
	// m_bCaptured is true when the miniframe is being dragged
	if (m_nHit != HTNOWHERE && !m_bCaptured)
	{
		UINT nHot = m_nHot;
		UINT nHit = m_nHit;
		StopCaptionButtonsTracking();
		if (nHot == nHit)
		{
			switch (nHit)
			{
			case HTCLOSE:
				if (OnCloseMiniFrame())
				{
					CloseMiniFrame();
					return;
				}
				break;

................................................


C#
void CPaneFrameWnd::CloseMiniFrame()
{
    ShowWindow(SW_HIDE);

    if (m_hEmbeddedBar != NULL)
    {
        CWnd* pEmbeddedWnd = CWnd::FromHandlePermanent(m_hEmbeddedBar);
        if (pEmbeddedWnd != NULL)
        {
            pEmbeddedWnd->ShowWindow(SW_HIDE);
        }
    }
}


Here the mini-frame wnd tell the embedded wnd to hide itself. Here the embedded wnd is the CDP wnd. So the CDP wnd just receive one WM_SHOWWINDDOW message. But it can't tell this event is triggered by x button.

How to capture the x button event when an CDP is in floating state? Do you have any idea about this? I ask google. But not exact answer...
Posted

1 solution

Please see the BOOL CPaneFrameWnd::OnCloseMiniFrame()

The main frame will receive the event by the call of
virtual BOOL OnCloseMiniFrame(CPaneFrameWnd* /*pWnd*/) ,

that you could try to overwrite for your main frame,
do something and return FALSE :)
 
Share this answer
 
Comments
SAMZCN 9-Sep-10 4:49am    
Hello, Eugen. Thanks for your great idea.... :)

That's great!!! Really it works....Here is my overriding.


BOOL CWSOMDIFrameWndEx::OnCloseMiniFrame(CPaneFrameWnd* pWnd)
{
CWnd* pPane = pWnd->GetPane();
if (pPane)
{
// do semething here ...
}
/*
virtual BOOL OnCloseMiniFrame(CPaneFrameWnd* pWnd) { return TRUE; }
*/
return CMDIFrameWndEx::OnCloseMiniFrame(pWnd);
}


Have a good day!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900