不知道我这个想法现不现实。在分割视图中,我想某一个浮动对话框只停留在某一个子视图中,怎么实现?谢谢!!

解决方案 »

  1.   

    比如:我分割了两个视图CToolView和CTextView 我要让浮动工具条限制在CTextView视图中移动下面这句应怎么修改?
    if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
    | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
    !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
    {
    TRACE0("Failed to create toolbar\n");
    return -1;      // fail to create
    }
      

  2.   

    获得CTextView的窗口区大小,设你获得后保存在CRect parentRect对象里面,将这个参数作为你浮动窗口的成员变量保存,然后重载你的浮动对话框的OnMove函数,在里面限制窗口的移动区域,m_Widht,和m_height为你的浮动窗口的宽度和高度,自己在OnInitDialog里面初始化void CRestrictDlg::OnMove(int x, int y) 
    {
    CDialog::OnMove(x, y);

    // TODO: Add your message handler code here
    CRect rect;
    GetClientRect(&rect);

    if (x<parentRect.left || y <parentRect.top)
    {
    MoveWindow(parentRect.left,parentRect.top,m_Width,m_height,TRUE);
    } if (x>parentRect.right-m_Width || y>parentRect.bottom-m_height)
    {
    MoveWindow(parentRect.right-m_Width,parentRect.bottom-m_height,m_Width,m_height,TRUE);
    }

    }