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.
Related
I have made a window in Qt C++ where inside I fill a table with items row by row. However, after I fill out enough rows, a scrollbar appears in order to allow me to scroll the extra rows. The problem is - when the scrollbar appears, it squeezes the table inwards. Is there some way to prevent this from happening?
I got a multiple selection CListBox with horizontal scroll bar enabled and showed correctly. Problem is, that when I use function
lst.ResetContent() and fill it back, I can't find way to scroll text in the rows back to the same position. I tried to use
lst.SetScrollPos(SB_HORZ, horizScroll, TRUE); , where horizScroll = lst.GetScrollPos(SB_HORZ); This works correctly on scroll bar itself, but
text in the row stays not scrolled (manual scrolling functions OK).
Structure of my program is:
CListBox lst;
int horizScroll;
/*Periodically doing code bellow*/
//Get current scroll position
horizScroll = lst.GetScrollPos(SB_HORZ);
//Reset current content
lst.ResetContent();
//Add item into CListBox (UNICODE in my application)
lst.AddString(L"Some longer text then width of CListBox");
//Calculate horizontal extent and set it through
lst.SetHorizontalExtent(calculatedWidth);
//Try to scroll text (scrolls only scroll bar, not text itself)
lst.SetScrollPos(SB_HORZ, horizScroll, TRUE);
UpdateData(FALSE);
Thanks in advance!
EDIT:
As "rrirower" answered correctly,
lst.PostMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, 250), 0);
message does the job. Scroll position from horizScroll works perfectly. I suggest posting this message twice, because if you do it only once, text is re-scrolled visually from beginning to the wanted position. When you post it twice, text visually stays at the correct position and scroll bar just quickly comes to the right place.
If I understand you correctly, you're trying to scroll the text in the list box horizontally using the program code. If you use Spy++, you'll see that when you manually scroll, using the mouse, a series of WM_HSCROLL messages is posted to the list box control. You can accomplish the same thing by doing this...
lst.PostMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, 250), 0);
You need to calculate the position (I used 250 above), but, the above code should move the text and the scroll bar horizontally.
After some reading it seems that Invalidate should do the trick. Since as I understand you have one text line this should be fine, however if the painting itself is complex and requires resources you can use ScrollWindowEx and then InvalidateRect on the rectangle returned by the latter to repaint only the changed area.
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.
I am in the process of making a Roku channel. The idea is to have a full screen player going, if the user presses a particular button on remote, a small pop up menu will display in a corner of the screen with a list of available channels. I have all working with the following exception: I can't figure out how to populate the area where the menu displays. Currently I have a transparent roImageCanvas on layer 1, the menu box is drawn on layer 2. The problem is that roImageCanvas allows for a text element but only one Item. So if I have a list of 10 channels, I would have to create 10 items on the canvas. The roImageCanvas does not accept arrays. So there is no way to create the pop menu on the fly if the number of channels changes. The number of items on the canvas has to be hard coded as far as I can tell. Ideally the roListScreen is what I would like to pop up but from what I understand all screens are full screen all the time. Does anybody know of a way to populate the targetbox on the canvas or create a screen that is resizable? Thanks for any suggestions
A roImageCanvas layer is an array. There is no technical limitation to you adding >1 elements to a layer and so you can add as many separate text items as you want (not hard-coded!). It seems to me best to have 1 text element per 1 menu item, so you can use their bounding rectangles (or text color) to highlight the choice
I'd like to change the default style of the list-view control's tooltips to balloon.
I first called ListView_GetToolTips() to get the HWND of the list-view's tooltips control, and then used GetWindowLongPtr()/SetWindowLongPtr() to add the TTS_BALLOON style.
I handle LVN_GETINFOTIP to customize the tooltip for the items (first column) in the list-view: the tooltip texts that appear for the first column items are actually a copy of the text of the third column. The other columns (subitems) are managed automatically by the list-view.
The balloon-style tooltips for the first column items seem OK; their stems are correctly positioned:
But the tooltips for the second column seem drawn wrongly, e.g. the balloon is drawn as if it was referred to a subitem in a row below the actual row pointed by the mouse cursor.
In the following picture, the "star" indicates the position in which the mouse cursor was when the tooltip appeared, but the tooltip's stem points to a row below, marked with an ellipse:
The strange thing is that the tooltips for the third column seem drawn correctly.
Is this a bug in the list-view control? (I'm using Windows 7.)
Or what am I missing here?
The ListView uses a tracking tooltip and positions it to unfold and reveal the hidden text in a column that's too small. It's not expecting its tooltip to be a balloon and so doesn't compensate for that.
You'd need to sub-class the tooltip itself, watch for TTM_TRACKPOSITION messages from the ListView, and adjust the coordinates.
Your second question - the shaded background comes from the system theme. You should be able to get it by calling SetWindowTheme on the tooltip (I'm not sure why the ListView disables themes for the tip).