CComboBox::SetItemHeight() increases both the Item and control height - mfc

I am using a class that is the descendant of CComboBox. The problem occurs when I call the CComboBox::SetItemHeight method to set the height of my combobox items using the following code:
m_searchComboBox.SetItemHeight(0,17);
It sets the height of Items but the height of the control (dropdown list) is also increased and the new height is larger than the height I set through Dialog Box. I also tried the following code:
m_searchComboBox.SetItemHeight(-1,17);
But that sets the height of the edit-control not the height of items. What should I do to set the height of Combobox items without disturbing the height of dropdown list?

Related

CListCtrl Does CListCtrl display only filled rows?

Is the default behaviour for CListCtrl to only show the number of rows that are currently filled with an empty greyed out area beneath?
In my List I have a variable number of entries in a fixed display area. When there are more entries than the display area can hold it is fine, the vertical slider comes up and everything displays correctly. When I delete entries so there are not enough now to fill the display area, the empty area at the bottom becomes greyed out with no cell grid.
I want to keep the display area set out as a complete cell grid. I can calculate and top up that area with empty rows if I have to but I wouldn't have expected this to be the default behaviour. I would have expected the whole Client area of the CListCtrl to stay permanently displayed as an empty cell grid with the correct number of entries displayed at the top.
Do I have to handle this manually or is there perhaps some property of the CListCtrl I am not setting?
What you have described IS the default behavior of the List View control:
Here is the relevant code fragment:
m_List.InsertColumn(0, L"Col 1", 0, 100);
m_List.InsertColumn(1, L"Col 2", 0, 100);
m_List.InsertItem(0, L"Item 1");
m_List.InsertItem(1, L"Item 2");
ListView_SetExtendedListViewStyle(m_List, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
You just need to make sure that you use current version of the Common Controls.

Set dynamically VertScrollBar property of the form based on label height - c++ builder

I'm using C++Builder 6.
I have a Form contain a TLabel.
I would like that the Form will contain a scroll bar when needed since sometimes the label text is too large to display.
What happens now is that the Form height grows as the Label height grows.
I would like that the Form height will be always <= a variable that I define, and that the VertScrollBar will appear when the label height is > that limit.
How to set the VertScrollBar property of the Form to support this?
Mainly, how to set the position and the range?
Set the Form's Contraints.MaxHeight property to the desired limit value, and set its AutoScroll property to true. Let the VCL manage the Form's scrollbars for you automatically when its content exceeds its width/height.
Alternatively, I would suggest getting rid of the TLabel and use a TRichEdit1 instead. Set its WordWrap to true, and its ScrollBars to ssVertical. It will auto-hide the scrollbar when it is not needed.
1: TMemo has the same ScrollBars property, but it does not hide the scrollbar when it is not needed.

Dynamically adjust the width of combobox so the entire string can be shown

I am using a combobox control to show names stored in a database ( I need to preserve space, that is why I use it instead of a listview, for example ).
My problem is that sometimes text is longer than the combobox so part of it can not be seen.
Is there a way to resize combobox' listbox so it can entirely show text, or at least to enable some kind of horizontal scrolling so the user can scroll to see the entire text?
Looking through combobox documentation, I haven't found any style that can solve my problem. Trying to add WS_HSCROLL as a style in my CreateWindowEx call didn't help either.
Thank you.
You are looking for the CB_SETHORIZONTALEXTENT message.
An application sends the CB_SETHORIZONTALEXTENT message to set the width, in pixels, by which a list box can be scrolled horizontally (the scrollable width). If the width of the list box is smaller than this value, the horizontal scroll bar horizontally scrolls items in the list box. If the width of the list box is equal to or greater than this value, the horizontal scroll bar is hidden or, if the combo box has the CBS_DISABLENOSCROLL style, disabled.
Parameters
wParam
Specifies the scrollable width of the list box, in pixels
lParam
This parameter is not used.

Set max width of a Gtk::TextView

I've created a textview which is being filled by a Gtk::TextBuffer, however the buffer contains a lot of characters and the window gets wider than the width of the screen.
Is there a way to define a max width for a Gtk::TextView?
Put the text view in a Gtk::ScrolledWindow and set the size request of the scrolled window.

How to increase a cells height and width in ListControl

How can we increase the the height and width of a cell in List
It is created using Listcontrol MFC
Write a custom list control (owner
drawn).
handle message MEASUREITEM_REFLECT
set the cell height and width in the
method:
MeasureItem( LPMEASUREITEMSTRUCT
lpMeasureItemStruct )
To set the cell width take a look at the ListView_SetColumnWidth Win32 function.
One way to set the height is to attach an image list to the list control. The list control will then set the row height based on the height of the icons in the image list.
An easy way to set the cell height of a list control is by supplying an image list of the required height:
In the header:
CImageList m_imageList;
In the implementation:
m_imageList.Create(68, 68, ILC_COLOR4, 10, 10); // 68 = cell height in pixels
m_list.SetImageList(&m_imageList, LVSIL_SMALL);
Setting the cell width is achieved by simply calling SetColumnWidth (as pointed out by jussij)