C++ MFC CComboBox is empty - c++

i've a little comboBox, and i want to fill it with 6 entries... .
i wrote this code:
CComboBox* dropdownList = ((CComboBox*)GetDlgItem(IDC_PROGRAMDROPDOWN));
dropdownList->Clear();
dropdownList->AddString(L"test");
dropdownList->AddString(L"test2");
dropdownList->InsertString(2,L"test3");
dropdownList->InsertString(3,L"test4");
dropdownList->InsertString(4,L"test5");
As you can see I tried AddString(), and InsertString(). both with no effect. I also tried it just with AddString() which should be the correct way at initializing it.
But, my combobox is empty. I already debugged it, and this lines are hit but with no effect.
Do you have any idea?

In the dialog editor, make sure you resize the ComboBox item so that its height is big enough to contain all of the items when the ComboBox is expanded. By default, it'll only be the height of the "edit control" bit of the ComboBox, which limits the expanded height.
So, in the dialog editor, click on the dropdown button bit of the Combo Box and you should see the drag handles change a bit. Drag out the new size to account for all the items in the dropdown list.

thanks for all your answers. But it was an ugly Failure by my IDE -.-. I just recreated the UI-Element and it worked...
I recreated it with the same properties (Copy & Paste)

Related

QCombobox - hide first item on drop-down

Hello fellow developers!
I want to realize a "Action" QCombobox where the different options trigger an action instead of choosing an option. The combobox says something like "Add Property" and when the user clicks it, he gets the different properties to choose from. If the user clicks one of them, it is added to -whateverdoesntmatter-. The combobox than switches back to it's original state.
The problem is, that the first entry "Add Property" is shown on the combobox's drop down, causing a little bit of confusion for the user since it is not really an action.
Normal state:
[Add Property]
Drop-down state:
[Add Property]
Add Property
Length
Width
etc ...
Therefore, I want to hide the first option as soon as the combobox drops down to achieve this behavior:
[Add Property]
Length
Width
etc ...
I have already tried with subclassing the combobox and overwriting showPopUp() and hidePopUp() - but I could not figure out how to get my intended behavior.
Ideas? Thanks!
If you don't absolutely need a QComboBox you might be better/easier off using a QToolButton with a QMenu associated and then set the button's popupMode to an appropriate value.
You may even use a QToolBar. Simply add a QAction with your desired label (like Add Property), associate the menu to it via QAction::setMenu and at it to the toolbar. The toolbar will automatically create the tool buttons itself.
To access the popupMode property you can use QToolBar::widgetForAction and cast it to a QToolButton.

the combobox dropdown list is so small that an updown arrows appear beside it

I have comboboxes that was built on the OWL I moved them to MFC and I faced alittle problem, the dropdown list of the combobox is so short that it shows only one item and you can navigate to the other items by using udown arrows like in the picture
the image on the left shows the short and incorrect one, the one on the right shows the release version that is working well.
what can cause this problem? and hoe to fix it. think it is style issue
Open dialog template in Resource Editor. Select combobox by mouse. Click on the "Down Arrow" element in the right part of the combobox (in your case it may be left part, according to localization). Then resize the combo to required height - in this state it resizes dropdown list. Build application and test dropdown list height at runtime - it should be OK.
http://msdn.microsoft.com/en-us/library/vstudio/4cta1x1t.aspx
See also: CB_SETMINVISIBLE message - allows to resize dropdown list size programmatically. I have never use it in my programs, though, so this is just a hint.

Remove the "Customize Quick Access Toolbar" button

I'm working on a project where we want to have a quick access bar that is unchangeable/static. We've looked at inheriting from the CMFCQuickAccessToolbar and removing that button, but those attempts seem fruitless. Just getting rid of the button completely gets rid of the toolbar. Anyone have some experience with this, or an alternative approach?
After a lot of headache we found that there was no clean solution to removing just that button from the toolbar. Instead, we opted to place the buttons we wanted to display in the quickaccess bar in the tabs group. These button will appear on the right side (beside the help icon in word). To replicate the look of the QA buttons, I had to create an imagelist and load our buttons into it.
CImageList theList;
CBitmap bm;
bm.LoadBitmap( IDB_QASMALL );
theList.Create(16,16, ILC_COLOR32 | ILC_MASK, 5, 0);
theList.Add(&bm, RGB(192,192,192));
I then created ribbonButtons to be added to the tabs group, with the proper command IDs, empty text, and the proper icon from my image list.
CMFCRibbonButton* button = new CMFCRibbonButton( ID_SOMECOMMAND, _T("\na"), theList.ExtractIcon(<IconOffset>));
m_wndRibbonBar.AddToTabs(mp);
It's not a perfect solution, but it at least gives us a similar UI without the worry of getting rid of that stupid customize button. You also have the freedom to use labels on your buttons.

combo box drop down is not working even after I changed the height in designer

I am trying to give a fix for a combo box drop down list, since its not listing down properly .Only one item is being shown in the list rest all you can see by using arrow keys. I increased the height in designer too, anyways that is not the issue, why because its listing down in some machines and the same version is not working on my machine. I used the DDX_Control to assign this control to a variable.
Do we need to consider any other things which can impact the drop down list??
environment : vs2008, windows 7
May be I didn’t explain the problem in the right manner. After some google search, I came to know that I should mention some more points here.
I embed this combobox in a dialog editor, there are already some comboboxes those are working fine.
They might be created with the earlier versions of VS. Even I tried to set the SetMinVisibleItems on this new combo, but always returns a failure.
The height of a dropped down combobox is indeed the height of the control in the dialog template. If you make your combobox tall enough in the designer, then it should show several lines when opened.
According to what you did, the correct behaviour is the other computers. The wrong behaviour is your computer.
No, there are no other things to consider when designing a combobox. Ues your debugger and try to find out why the height of your combobox was reduced on your computer.
That can happen if the No Integral Height combobox property is set to true, and the height of the listbox component of the combobox has been inadvertently set to that of the combobox component.
The dialog designer allows you to set both of these two heights. Click on the dropdown arrow icon and then the bottom node then adjusts the listbox component. Change that height to be what you want, and set No Integral Height to be false.
This doesn't explain why it works on other machines, but give it a try.

Help finding issue with tooltip on CMFCMenuBar

I have an MFC app using the new UI features released in the Feature Pack and I'm having trouble with tooltips on the menubar.
By default, I beleive tooltips are not enabled on menu items. Yet whenever I hover over the 2nd item in any of the menu lists I get a tooltip with "Untitled" in the popup. The only time this does not occur is when the second item is a seperator. This only occurs on the 2nd item, not on any other item in the list. What's also odd is that a tooltip popup appears when hovering over the "Edit" top level menu item.
So to illustrate, top level menu:
File Edit View Help (Hovering over "Edit" displays the tooltip)
To Illustrate the File menu
File
New
Open
Save
Save As
(Hovering over "Open" displays the tooltip)
Again the same behavior occurs for the second item on each of the menu sections. None of the other mennu items display tooltips.
Any help on how I might be able to pin down this probelm is much appreciated.
Found the problem. Without going into the back story, I had to merge resource ID's from another project into the Resource.h file in this project. IDR_MAINFRAME was set to a value of 2 from a very old project. MFC apparently does not like 2 for this resource ID. I change it to 128 which seems to be the default value used by the new app wizard. All is well now.