Starting with Windows 95 and NT 3.51, the so-called common controls ("common" window controls, or controls) have been added to the main set of windowing classes in Microsoft operating systems. Among them there is also a window for viewing lists of arbitrary elements, texts and images - list view. In the KOL library, all "common" controls are also implemented inside the TControl object type. Moreover, in many cases the polymorphism of methods, properties and events is preserved, so that in terms of the external interface for the programmer, the "general" controls practically do not differ from the original window objects (the so-called GUI windows, GUI - Graphic User Interface, or graphical user interface) ...
Shared List Constructor:
NewListView(Parent, style, options, IL_normal, IL_small, IL_state);
The constructor immediately sets the style (lvsIcon - icons, lvsSmallIcon - small icons, lvsList - list, lvsDetail - detailed, lvsDetailNoHeader - detailed without a header), lists of images (IL_normal - for the "icon display" style, IL_small - - to store the "state" icons displayed in a separate column in the lvsDetail and lvsDetailNoHeader styles; nil can be passed in place of any lists if the list is not used), as well as options:
lvoIconLeft - in the lvsIcon, lvsSmallIcon modes, place the icon to the left of the text (and not above the text, as by default);
lvoAutoArrange - automatic ordering of items in the lvsIcon and lvsSmallIcon view modes;
lvoButton - icons are displayed as buttons (for lvsIcon view mode);
lvoEditLabel - editing of the text of labels is allowed (the first column of the element);
lvoNoLabelWrap - the text is always displayed in one line (for the lvsIcon view mode);
lvoNoScroll - no scrolling in the window;
lvoNoSortHeader - do not try to sort items when you click on the column header button;
lvoHideSel - hide selection when the window is not in focus;
lvoMultiselect - allows multiple selection;
lvoSortAscending - Sort Ascending;
lvoSortDescending - sorting in descending order (if neither ascending nor descending sort is specified, then automatic sorting is not performed);
lvoGridLines - a grid of rulers between columns and rows;
lvoSubItemImages - columns can contain their own icons;
lvoCheckBoxes - system switches are used as images;
lvoTrackSelect - tracking the mouse cursor, and additional visual effects when the cursor crosses the elements;
lvoHeaderDragDrop - it is allowed to grab and drag column headers (lvsDetail mode), changing the display order columns;
lvoRowSelect - the entire line is selected, with all columns;
lvoOneClickActivate - single mouse click activates the element;
lvoTwoClickActivate - double click of the mouse activates the element;
lvoFlatsb - flat scroll bars;
lvoRegional - a special "transparency" mode, in which all client space, except for the elements themselves and their icons, is excluded from the window region;
lvoInfoTip - automatically create and display a window, which reflects the entire text of the column under the mouse cursor, if this text is not fully visible in the column itself;
lvoUnderlineHot - underline active elements (under the mouse cursor);
lvoMultiWorkares - use multiple working areas in the window (for viewing and automatic ordering in lvsIcon mode);
lvoOwnerData - the list is virtual, i.e. initially does not store any data itself, but in the OnLVData event handler receives their custom code;
lvoOwnerDrawFixed - a list of elements of the same height, displayed by the custom OnDrawItem handler (this style should not be used if the OnLVCustomDraw event is used).
At runtime, the view style can be changed (or obtained) by the LVStyle property. Moreover, it is possible to change any options of the general list dynamically using the properties of LVOptions.
|
Regarding the lvsDetail and lvsDetailNoHeader viewing styles, it should be noted that the text and images of list items in these modes are displayed in columns. But you need to create columns with your own code (or use the column editor at the development stage). If this is not done, the list box will remain empty, even if there are items in it! |
For a general list, including those with multiple selection, including for the case when the selected elements are not adjacent, the SelLength property continues to work - it returns the number of selected elements. But in code it is better to use the LVSelCount property.
As usual, for list controls, the Count property also works (there is a synonym for it - the LVCount property), but for a virtual list this property can be set by telling the object window how many elements there are (shown) in the list.
|
Note. The effect of the "erroneous" appearance of empty (inaccessible to the user) lines before the very first line of the virtual list is known, if at the moment of changing the number of elements the scroll bar was not in the top position (lvsDetail and lvsDetailNoHeader modes). A completely similar effect can be obtained for the virtual list TListView and in the VCL. You can avoid the appearance of such empty lines if, before changing the Count property, you put the object in lvsList view mode (for example), set the Count value to 0, and then return the image to lvsDetail or lvsDetailNoHeader mode; this problem is solved in a similar way for VCL applications. At least in my applications, this was the way to fix this failure. |
The OnMeasureItem event (see the Set_LVItemHeight method) can be used if the lvoOwnerDrawFixed style is present in order to programmatically set the height of an item if the system's default height is not satisfactory. Personally, I often use another method: assign an object a list of images (in accordance with the view mode - a list for large or small icons, depending on the view modes used). The size (height) of the icon in such a list of images also uniquely determines the height of the elements, as long as it is larger than the height of the font used (if the font is larger, then the height of the element is set by the system so that the text fits completely in height). If the list of images itself is not used, it is not necessary to fill it with anything. An empty list is enough to set the required element height.
As with other list controls, the Clear method continues to work (perhaps the most polymorphic method for all kinds of window objects).
The general list is characterized by the property SetUnicode(b)- puts the object window into the mode of processing Unicode strings. To provide the ability to work with Unicode strings in list items, you must also add the conditional compilation symbol UNICODE_CTRLS * to the project options;