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

问题描述

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

 虚拟  void  OnPressCloseButton();
用户按下控制栏上的关闭按钮时,框架会调用此功能  -string>' 字幕.在派生类中重写它以获取有关此事件的通知. 



但是,当CDP浮动但未停靠时,这似乎不起作用.浮动时,CDP在一个迷你帧中.小型框架wnd将按以下方式处理此事件...

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

    如果(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按钮事件?您对此有任何想法吗?我问谷歌.但不是确切答案...

解决方案


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

解决方案


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

09-26 06:01