Cmfctoolbarcomboboxbutton从注册表中提取旧数据 [英] Cmfctoolbarcomboboxbutton bring old data from registry

查看:71
本文介绍了Cmfctoolbarcomboboxbutton从注册表中提取旧数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用MFC功能包在工具栏中添加了一个ComboBox。我一直很成功,它正在发挥作用。 ComboBox中的文本选项必须根据外部因素进行更改,因此当您运行问题时,它们可能是选项#1,选项#2等,或选项A,选项B等。



我的问题是程序读取CMFCToolBarComboBoxButton从注册表中的内容总是带来最后一组的选项,尽管我装一个diferent之一,当我创建了CMFCToolBarComboBoxButton,也做了ReplaceButton 。



如果我删除了注册表,它第一次正常工作,但第二次再次加载上一组文本。



有没有办法禁用此功能?我还没有找到任何帮助



我还检查了VS2010中包含的VisualStudioDemo示例程序,我得到了相同的结果。我更改了线条的文字,它没有出现在组合框中,直到我重置工具栏。



任何帮助将非常欢迎

谢谢



我尝试过:



这个是我的代码的恢复<预郎= C ++> {
...

CMFCToolBarComboBoxButton comboButton(ID_DESTINOS,GetCmdMgr() - > GetCmdImage(ID_DESTINOS,FALSE),CBS_DROPDOWNLIST) ;

if (Set()== 1
{
comboButton.AddItem(_T( OPTION#1));
comboButton.AddItem(_T( OPTION#2));
}
else
{
comboButton.AddItem(_T( Diferent #A));
comboButton.AddItem(_T( Diferent #B));
}

comboButton.SelectItem( 0 );
m_wndToolBar.ReplaceButton(ID_DESTINOS,comboButton);

...

}

解决方案

您的代码段让我担心位,因为按钮的本地范围。使用这样的对象作为类指针。



所以你的标题应该包含类似的行:

 CMFCToolBarComboBoxButton * m_ComboButton 



正确的UI处理是示出了并在此讨论的 MSDN讨论



确保您在加载代码后修改工具栏


I have added to my program a ComboBox in the toolbar using the MFC Feature pack. I have been success with it and it is working. The text options in the ComboBox must change according external factors, so when you run the problems they could be "Option #1", "option #2", etc or "Option A", "Option B", etc.

My problem is the program reads the content of the CMFCToolBarComboBoxButton from the registry always brings the last set of options, despite I loaded a diferent one when I created the CMFCToolBarComboBoxButton and did the ReplaceButton.

If I delete the registry it works fine the first time, but the second time loads again the previous set of texts.

Is there any way to disable this feature ? I haven´t found any help out there

I have also checked with the VisualStudioDemo example program included in the VS2010 and I had the same result. I change the text of teh lines and it doesn´t show up at the combobox until I reset the toolbar.

Any help will be very welcomed
Thank you

What I have tried:

This is a resume of my code

{
...

CMFCToolBarComboBoxButton comboButton( ID_DESTINOS, GetCmdMgr()->GetCmdImage(ID_DESTINOS, FALSE), CBS_DROPDOWNLIST);

if( Set() == 1)
{
	comboButton.AddItem( _T("OPTION #1"));
	comboButton.AddItem( _T("OPTION #2"));
}
else
{
	comboButton.AddItem( _T("Diferent #A"));
	comboButton.AddItem( _T("Diferent #B"));
}

comboButton.SelectItem( 0);
m_wndToolBar.ReplaceButton( ID_DESTINOS, comboButton);

...

}

解决方案

Your code snippet worries me a bit, because of the local scope of the button. Use such object as class pointer.

So your header should include a similar line like that:

CMFCToolBarComboBoxButton *m_ComboButton


The correct UI handling is shows and discussed on this MSDN discussion.

Ensure that you modify the toolbar after the loading code.


这篇关于Cmfctoolbarcomboboxbutton从注册表中提取旧数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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