关于EnableDocking的停靠问题?

sinet_emperor 2002-07-04 09:46:49
我用分割条把框架分为两三个视,那我能不能把工具条或控制条停靠在其中的任何视内呢,而不停靠在框架上,可行吗?特别是对于控制条的情况.当然对于工具条或控制条,我们在创建时可以把它的父指针指向视图的窗口句柄中。
...全文
906 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
蒋晟 2002-07-04
  • 打赏
  • 举报
回复
在Splitter Pane里面放Frame……以前做过,但是好像没有成功
建立的Frame游离于Splitter Pane之外……
sinet_emperor 2002-07-04
  • 打赏
  • 举报
回复
我照这个方法适了一下,控制条没有显示出来,不知什么问题,这是代码:
CCOOLBAR m_wndDialogBar;
CTestDialog m_cMidCtlBarDlg;
void CEditViewEx::OnInitialUpdate()
{
CEditView::OnInitialUpdate();

if (!m_wndDialogBar.Create(this, &m_cMidCtlBarDlg, CString("test"), IDD_COOLBAR))
{
TRACE0("Failed to create dialogbar\n");
return ; // fail to create
}
m_wndDialogBar.SetBarStyle(m_wndDialogBar.GetBarStyle()|CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

CRect rcClientOld;
CRect rcClientNew;
GetClientRect(rcClientOld);

RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0,reposQuery,rcClientNew);

CPoint ptOffset(rcClientNew.left-rcClientOld.left,rcClientNew.top-rcClientOld.top);

CRect rcChild;
CWnd *pwndChild = GetWindow(GW_CHILD); //得到子窗口
while(pwndChild) // 处理所有子窗口
{//移动所有子窗口
pwndChild->GetWindowRect(rcChild);
ScreenToClient(rcChild);
rcChild.OffsetRect(ptOffset);
pwndChild->MoveWindow(rcChild,FALSE);
pwndChild = pwndChild->GetNextWindow();
}

CRect rcWindow;
GetWindowRect(rcWindow); // 得到对话框RECT
rcWindow.right += rcClientOld.Width() - rcClientNew.Width(); // 修改对话框尺寸
rcWindow.bottom += rcClientOld.Height() - rcClientNew.Height();
MoveWindow(rcWindow,FALSE); // Redraw Window
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);
}
wistaria 2002-07-04
  • 打赏
  • 举报
回复
1. 在资源中加入IDC_TOOLBAR1工具栏资源
2. 在.h文件中加入CToolBar m_wndToolBar;变量
3. 在.cpp文件中OnInitialUpdate中加入
if(!m_wndToolBar.Create(this) || !m_wndToolBar.LoadToolBar(IDR_TOOLBAR1))
{
TRACE0("Failed to Create Toolbar\n");
}
CRect rcClientOld; // Old Client Rect
CRect rcClientNew; // New Client Rect with Tollbar Added
GetClientRect(rcClientOld); // Retrive the Old Client WindowSize
// Called to reposition and resize control bars in the client area of a window
// The reposQuery FLAG does not really traw the Toolbar.
// It only does the calculations.
// And puts the new ClientRect values in rcClientNew
// so we can do the rest of the Math.
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0,
reposQuery,rcClientNew);

// All of the Child Windows (Controls) now need to be moved
// so the Tollbar does not cover them up.
// Offest to move all child controls after adding Tollbar
CPoint ptOffset(rcClientNew.left-rcClientOld.left,
rcClientNew.top-rcClientOld.top);

CRect rcChild;
CWnd* pwndChild = GetWindow(GW_CHILD); //Handle to the Dialog Controls
while(pwndChild) // Cycle through all child controls
{
pwndChild->GetWindowRect(rcChild); // Get the child control RECT
ScreenToClient(rcChild);
rcChild.OffsetRect(ptOffset);
// Changes the Child Rect by the values of the claculated offset
pwndChild->MoveWindow(rcChild,FALSE); // Move the Child Control
pwndChild = pwndChild->GetNextWindow();
}

CRect rcWindow;
GetWindowRect(rcWindow); // Get the RECT of the Dialog
rcWindow.right += rcClientOld.Width() - rcClientNew.Width();
// Increase width to new Client Width
rcWindow.bottom += rcClientOld.Height() - rcClientNew.Height();
// Increase height to new Client Height
MoveWindow(rcWindow,FALSE); // Redraw Window

// Now we REALLY Redraw the Toolbar
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);
Lemon_2000 2002-07-04
  • 打赏
  • 举报
回复
up
sinet_emperor 2002-07-04
  • 打赏
  • 举报
回复
我原本想把一个控制条放在一个ceditview的视中的顶部,创建没有出错,但调用停靠的函数时就出错了,应该就是和Frame有关,我不知道怎么解决??高手帮帮忙
zhishao 2002-07-04
  • 打赏
  • 举报
回复
可行。

参照afxwin.h及winfrm2.cpp的实现方式写一个具有Frame特征的View。

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧