MFC控件积累——CDockablePane控件

来源:互联网 发布:网络stp 编辑:程序博客网 时间:2024/05/21 06:49

1.控制多个CDockablePane停靠在一起时,先停靠一个窗口:

DockPane(&m_dockPane1);//使用CFrameWndEx::DockPane()

  void DockPane(     CBasePane* pBar,//A pointer to the control bar to be docked.     UINT nDockBarID=0,   //The ID of the side of the frame window to dock to.控制停靠位置     LPCRECT lpRect=NULL   );

  在该窗口的位置继续停靠其他窗口:

m_dockPane2.AttachToTabWnd();//使用CDockablePane::AttachToTabWnd()

  virtual CDockablePane* AttachToTabWnd(       CDockablePane* pTabControlBarAttachTo,//停靠到      AFX_DOCK_METHOD dockMethod,//停靠方式,DM_SHOW      BOOL bSetActive = TRUE,//TRUE to activate the tabbed pane after the attach operation; otherwise, FALSE.        CDockablePane** ppTabbedControlBar = NULL  ); 
需要注意的是,在DockPane的时候控制停靠的位置,在AttachToTabWnd时控制最后被激活的页面。

To make your tab have Outlook style, pass AFX_CBRS_OUTLOOK_TABS as the seventh argument to the Createfunction when creating your pane.

2.Tips

  • To disable loading of docking layout from the Registry, make the following call in the frame constructor:
    GetDockingManager()->DisableRestoreDockState(TRUE);
  • Always define your dockable pane destructor as virtual, this will save a lot of debugging time and possible memory leaks.
  • To prevent your pane from docking by user, pass CBRS_NOALIGN to the pane's EnableDocking function .


参考文章:CodeProject上的《Understanding CDockablePane》

3.今天解决一个非常奇怪的问题,问题是这样的:我的工程从VC6.0的MFC框架版本移植成为CMFCxx类框架版本,但继承CDockablePane窗口类创建的停靠窗口,当鼠标移动到停靠窗口边缘时,本来鼠标应该变为可以拖拽的样子,但我的程序中变成了鼠标消失了,但仍然可以拖动改变窗口大小,查找了各种原因包括使用的框架创建有没有不适合的地方,CDockablePane创建是否正确,都不是这些原因,最终在.rc资源文件中找到了原因:多余的宏定义_AFX_NO_SPLITTER_RESOURCES,分析原因应该是原本的鼠标资源被排除在工程外,导致鼠标资源加载不正确造成。查看MSDN有以下资料:
_AFX_NO_XXX 宏不用于定义或未定义的 MFC 的用户。仅用于检查特定目标平台是否支持该功能,或不存在这些宏。您可以编写程序来检查这些宏 (例如,#ifndef _AFX_NO_OLE_SUPPORT),但您的程序应该永远不会定义或取消定义这些宏。
如果定义了 _AFX_NO_OLE_SUPPORT,症状可能包括:

  • 在应用程序启动时遇到访问冲突。
  • InitInstance 不会调用 DLL 中。
不应定义其他宏:

_AFX_NO_AFXCMN_SUPPORT
_AFX_NO_CTL3D_RESOURCES
_AFX_NO_DAO_SUPPORT
_AFX_NO_DB_SUPPORT
_AFX_NO_MAPI_RESOURCES
_AFX_NO_NESTED_DERIVATION
_AFX_NO_OCC_SUPPORT
_AFX_NO_OCX_SUPPORT
_AFX_NO_OLE_SUPPORT
_AFX_NO_RICHEDIT_SUPPORT
_AFX_NO_SOCKET_SUPPORT
_AFX_NO_SPLITTER_RESOURCES
_AFX_NO_SYNC_SUPPORT
_AFX_NO_TRACKER_RESOURCES


0 0