Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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
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);

...

}
Posted
Updated 18-May-17 1:41am
v3
Comments
Richard MacCutchan 22-Apr-17 4:38am    
That code does not match your problem description.

1 solution

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:
C++
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900