处于浮动状态时,如何捕获CDockablePane x按钮事件? [英] How to capture CDockablePane x button event when it is in floating state?

查看:160
本文介绍了处于浮动状态时,如何捕获CDockablePane x按钮事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个浮动CDockablePane(CDP).我想在使用捕获区域上的"x"按钮执行其他操作时捕获关闭事件. MSDN说我可以在OnPressCloseButton()中做到这一点

 虚拟  void  OnPressCloseButton();
用户按下控制栏上的关闭按钮时,框架会调用此功能  -string>'   void  CPaneFrameWnd :: CloseMiniFrame()
{
    ShowWindow(SW_HIDE);

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



在这里,迷你框架将告诉嵌入式wnd隐藏自身.这里的嵌入式Wnd是CDP Wnd.因此CDP只会收到一条WM_SHOWWINDDOW消息.但这不能说此事件是由x按钮触发的.

CDP处于浮动状态时如何捕获x按钮事件?您对此有任何想法吗?我问谷歌.但不是确切答案...

解决方案

请参阅BOOL CPaneFrameWnd::OnCloseMiniFrame()

主机将通过
的调用接收事件 virtual BOOL OnCloseMiniFrame(CPaneFrameWnd* /*pWnd*/)

您可以尝试覆盖主框架,
做某事并返回FALSE:)


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()

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;

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



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...

解决方案

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 :)


这篇关于处于浮动状态时,如何捕获CDockablePane x按钮事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆