CDockablePane停靠窗口,当点击‘x’按钮关闭pane时候,我想捕获这个事件做其他的处理。结果遍寻google和baidu无果Bill说:
CPane::OnPressCloseButton
Visual Studio 2010Other Versions Visual Studio 2008Called by the framework when the user presses the close button on the caption for the pane.Copyvirtual void OnPressCloseButton();
Res
--------------------------------------------------------------------------------This method is called by the framework when a user presses the Close button on the pane's caption. To receive notifications about the Close event, you can override this method in a derived class.结果我发现当pane在floating状态,根本不会执行这个函数,而是进入了floating状态的CloseMiniFrame()函数。这个是MFC的代码,真的没有其他办法了么???有熟悉sp1的tx么?最近本sp1折腾的厉害不熟悉就是不行

解决方案 »

  1.   

    饿 没用过 LZ不妨试试用spy++当pane在floating状态时收到了撒消息 处理下
      

  2.   

    唉。只是收到了一个WM_SHOWWINDOW消息,这个消息随便啥时候都能收到。我根本无从判断是不是因为点击了x按钮发送的WM_SHOWWINDOW消息郁闷
      

  3.   

    大概试验了下点 ‘x’  不进  onclose()而是进          OnShowWindow()关掉后显示这个窗口 也掉这个函数。OnShowWindow()在这个函数中加入 AfxMessageBox() 点 ‘x’ 后有效,但是重新显示的时候仍然  AfxMessageBox()
      

  4.   

    是的,后来在codeproject.com问人给了一个方案。重载CMDIFrameWndEx的OnCloseMiniFrame()函数可以变通的截获x按钮事件。然后结合OnShowWindow函数处理即可实现处理。
      

  5.   

    建议将这个窗口子类化,然后在收到DESTROY消息时干你想干的事
      

  6.   

    BOOL CMainFrame::OnCloseMiniFrame(CPaneFrameWnd* /*pWnd*/)
    {
    return FALSE;
    }BOOL CMainFrame::OnCloseDockingPane(CDockablePane* /*pWnd*/)
    {
     return FALSE; 
    }果然解决问题!
    比如我添加的这两句,那个窗口无论停靠还是浮动都不可关闭,呵呵。
    就是不知道要是想在让那个“X”不可见,咋弄。