CMFCToolBar定制问题 [英] CMFCToolBar customization problems

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

问题描述

嗨.我在将较旧的应用程序升级到新的MFC时遇到了一些问题.看完所有地方之后,我似乎仍然无法重新创建所需的工具栏.

我有一个MDI应用程序,带有MenuBar和标准ToolBar,并且我想为文本创建一个附加的CMFCToolBar.格式化,包括CMFCToolBarFontComboBox,CMFCToolBarComboBox和其他类型的按钮.

为简化起见,让我们考虑添加CMFCToolBarFontComboBox.

我的问题:

Hi. I'm having a few problems upgrading an older application to the new MFC. After reading all over the place, I still can't seem to recreate the toolbar I need.

I have an MDI application, with the MenuBar and the standard ToolBar, and I want to create an additional CMFCToolBar for text formating, which includes a CMFCToolBarFontComboBox, a CMFCToolBarComboBox and other type of buttons.

To make things simpler, let's just think about adding the CMFCToolBarFontComboBox.

My problem:

The CMFCToolBarFontComboBox按钮未显示.

The CMFCToolBarFontComboBox button doesn't show.

环顾四周后,这是我发现的最明智的方法,但仍然无法正常工作.

我创建了CMainFrame创建函数中的其他工具是这样的:(m_wndTextBar是CMFCTextToolBar,它扩展了CMFCToolBar)

After looking around, this is the most sensible way I found to do this, but it still doesn't work.

I create the additional tool in the CMainFrame create function like this: (m_wndTextBar is a CMFCTextToolBar, which extends CMFCToolBar)

如果(!m_wndTextBar.CreateEx(this,TBSTYLE_FLAT,WS_CHILD | WS_VISIBLE CBRS_TOP CBRS_GRIPPER CBRS_TOOLTIPS CBRS_FLYBY CBRS_SIZE_DYNAMIC)||
!! m_wndTextBar.LoadToolBar (IDR_TEXTTOOLBAR_​​256))
{
TRACE0(无法创建文本工具栏\ n");
返回FALSE; //创建失败
}
m_wndTextBar.SetWindowText(_T(" Format")));
if (!m_wndTextBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || 
    !m_wndTextBar.LoadToolBar(IDR_TEXTTOOLBAR_256)) 
    TRACE0("Failed to create text toolbar\n"); 
    return FALSE;      // fail to create 
m_wndTextBar.SetWindowText(_T("Format")); 

推荐答案

我发现了问题的一部分.将按钮添加到MFCToolBar时,如果您之前已启动该程序并启用了工具栏自定义功能,该按钮将不会显示.这是因为工具栏属性是在注册表中设置的,并在运行时加载.要查看该按钮(在这种情况下为MFCToolBarFontComboBo),您需要重置"工具栏,然后瞧瞧按钮显示.

但是,我仍然遇到一些问题.

其中两个可能相互联系.即使我使用以下命令设置了第二个工具栏文本:

I figured part of the problem. When adding a button to an MFCToolBar, the button will lickely not show if you've started the program previously and have toolbar customization on. This is because the toolbar properties are set in the registry and loaded at runtime. To see the button, in this case an MFCToolBarFontComboBo, you need to 'Reset' the toolbar, and voila the button shows.

However, I still have some problems.

Two of them might be interrelated. Even though I set the second toolbar text using:


m_wndTextBar.SetWindowText(_T("Format")); 


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

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