VS2010中有两个cmfctoolbars对接问题 [英] Two cmfctoolbars docking problems in VS2010

查看:89
本文介绍了VS2010中有两个cmfctoolbars对接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我很感激有人可以帮我诊断出以下问题:现在我正试图在vs2010 SDI应用程序上放两个CMFCToolBars。但他们现在有对齐问题。第一个工具栏很好地落在菜单栏下,但第二个工具栏似乎总是飞来飞去。在大多数情况下,它似乎垂直连接到客户区的左边缘......我整天都在玩这个,不得不在这里提出一些想法。我相信这是一个有趣的问题,因为我注意到有些人遇到了这个问题但是VS6只有一些可能的解决方案...



谢谢。



Hello, I appreciate it if someone can help me to diagnose the following problem: right now I'm trying to put two CMFCToolBars on a vs2010 SDI application. But they are having alignment problems now. The first toolbar falls nicely under the menubar, but the second seems always flying around. At most cases, it appears vertically attached to the left edge of the client area... I was playing this all day long and have to ask some ideas here. I believe this is a interesting question as I notice some people had this problems but there were only some likely solutions for VS6...

Thanks.

if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(1, 1, 1, 1), IDR_MAINFRAME_256 ) ||
		!m_wndToolBar.LoadToolBar( IDR_MAINFRAME_256 ))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}


	m_wndToolBar.SetWindowText(_T("test1"));
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);

	//DockControlBar((CControlBar *)&m_wndToolBar,AFX_IDW_DOCKBAR_LEFT, &rect);

	if (!m_wndToolBar1.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(1, 1, 1, 1), IDR_SORT )||
		!m_wndToolBar1.LoadToolBar(IDR_SORT))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}


	m_wndToolBar1.SetWindowText(_T("test"));
	m_wndToolBar1.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_wndToolBar);
	DockPane(&m_wndToolBar1);





我尝试过:



VS2010中的两个CMFCToolBars对接问题



What I have tried:

two CMFCToolBars docking problems in VS2010

推荐答案

谢谢Rick,我试过了这个功能。在我看来,我必须强制将CMFCToolBar *转换为参数定义的CControlBar *。当程序调用DockControlBarLeftOf(this,m_wndToolBar1,m_wndToolBar)时,这会导致崩溃。有没有解决这个问题?
Thanks Rick, I tried the function. It seems to me I have to force convert the CMFCToolBar* to CControlBar* as defined for the parameters. This results in a crash when the program calls DockControlBarLeftOf(this, m_wndToolBar1, m_wndToolBar). Is there any fix for this?


嗨Rick,我没有尝试过DockPaneLeftOf()。但是,在CreateEX()中创建工具栏时,我通过操作几个ID参数找到了解决方案。我所做的是使用IDR_TOOLBAR1 | AFX_IDW_TOOLBAR替换独奏ID IDR_TOOLBAR1。我想VS2010把它作为第二个CMFCToolBar(m_toolbar1)是另一个'主要'工具栏的指示,并把它放在左边的另一行...





再次感谢。
Hi Rick, I did not try DockPaneLeftOf(). However, I figured out a solution by manipulating few ID parameters when creating the toolbar in CreateEX(). What I did is using IDR_TOOLBAR1|AFX_IDW_TOOLBAR replacing a solo ID IDR_TOOLBAR1. I guess VS2010 takes it as a indication that the second CMFCToolBar ( m_toolbar1) is another 'prime' toolbar and put it in another line from left...


Thanks again.


这篇关于VS2010中有两个cmfctoolbars对接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆