How to set font in edit box part of a CMFCToolBarComboBoxButton? - mfc

I'm able to set the font used to draw the drop-down part of a CMFCToolBarComboBoxButton combo box which is embedded in a CMFCToolBar toolbar. However, I'm not able to set/change the font used for the edit field control which is part of the combo box. I.e., when the combo box is collapsed the currently selected item is always drawn with the standard/default font no matter what font is used for the entries when expanding the box.
I successfully change the font of the drop down box part by using a pointer to the underlying CComboBox object retrieved via CMFCToolBarComboBoxButton::GetComboBox() (and then via CComboBox::SetFont(...)). But when using the method CMFCToolBarComboBoxButton::GetEditCtrl() to obtain a pointer to the edit control part (in order to change its font, too) this method always returns a nulltpr. Does anybody know why or more importantly: What is the correct way to set the font used for the edit control part of the box?
I've searched the web now quite a lot but cannot find a solution to the problem. Thanks for any advice!
Additional note: I need to change the used font(s) at run time in my MFC application.

OK, I finally came to the conclusion that it's better to leave these fonts up to the OS settings anyway and not explicitly set them by the application code.
This is not a technically correct answer to the (my own) question, certainly, but may be a good advide for others chasing the same problem.

Related

Customizing CMFCRibbonBar im MFC

I am trying to customize the default MFC RibbonBar. I need to reduce its height, change its color etc, but so far i haven't found anything on how to do so. I've been to msdn, and they just tell you how to add new controls on the ribbon.Can any one please point me in the right direction? Is this ribbon control even customize-able? i mean apart from adding categories and other controls on it, i want to change the look of the ribbon.
Some code samples about how to work with MFCRibbonControl would be of great help too.

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.

create a scrollbar in a submenu qt?

I have a map application and a submenu which has dynamically added objects (i.e. points on a map) added to the submenu, depending on the layer that is loaded. I have the ability to hide each individual objects (i.e. a point) by clicking on the corresponding submenu item. Is there any way to organize the submenu? When there are a lot of points (i.e. 100) the entire submenu takes up the screen. Can I add a scrollbar to a submenu? I looked in the documentation, but couldn't find anything that support this feature.
From this bug report I was able to find out that you could do the following:
submenu->setStyleSheet("QMenu { menu-scrollable: 1; }");
Works like a charm.
There is no such possibility as far as I know.
Maybe you shouldn't use a sub menu for this but prefer a menu entry that show a Point manager GUI of your own which would have a QListWidget displaying all your points items.
I'm aware that this solution will break a (big?) part of your code but I don't see anything else.
I think you may be able to get the effect you want by creating and using your own QStyle subclass (via QApplication::setStyle()), and overriding the styleHint virtual method to return 1 when the StyleHint parameter passed in is SH_Menu_Scrollable. At least, that works for me when I create large QMenu objects and show them as popup menus.... It may also work for QMenus attached to the menu bar, but I havent tried that.
Whilst it is possible by subclassing the QMenu class to create a custom widget and going from there you're better off looking at a better way to display that information. You'll save yourself time and it'll be much easier for your users to not have to scroll through a big list of items in a small area.

Qt: How to show icon when item selected

I have a QListWidget containing items which have icons and when the items are selected the icon is just highlighted out. Is there a way to prevent this? I can't use stylesheets because it's for an embedded application and including them takes up too much space.
thanks
I suppose when you say "Highlithed out", you mean that the icon colors don't render well when the line is selected, and therefore, you can't see properly the icon...
Maybe you could consider using a different icon when the item is selected. It's possible to do so by specifing a mode to your icon.
Example :
QIcon MyIcon(":/images/foo");
MyIcon.addFile(":/images/bar", QSize(...), QIcon::Selected);
You can easily make a try in QtDesigner and see the results...
Hope it helps a bit !
Certainly, drawing on a black-and-white screen presents its challenges.
It sounds like you just want to change the appearance of the interface, not any functionality. If this is the case, a QItemDelegate-derived class (or QStyledItemDelegate) is almost certainly what you want. In particular, the drawDecoration function looks like it is used to draw an icon, and the style options should include whether it is selected. The simplest fix would be to override that function, set the selected flag in the options to false, then pass it up to the parent's function.

MFC - How can I disable a list item?

I have a CListCtrl with checkboxes. I want to be able to disable one of the items so that the user cannot click the checkbox. Is this possible? If so, how?
Edit:
Found the specifics on how to hide a checkbox in another question
Need only some rows in a CListCtrl control to have check boxes
Shortly: Not easily possible.
You'll need to sub-class the CListCtrl and implement this behavior on your own or download for example the MFC Grid Control that allows you to do that.
As for the removing check-boxes idea, yes, that might be possible, MSDN:
Version 4.70. Enables check boxes for items in a list-view control. When
set to this style, the control creates
and sets a state image list with two
images using DrawFrameControl. State
image 1 is the unchecked box, and
state image 2 is the checked box.
Setting the state image to zero
removes the check box.