List-View – Giavapps Windows API

 

 

api_listview_create(ParentHandle, X, Y, W, H, Flags, ExFlags) This function creates a list-view control.

ParentHandle: parent handle.
X: x coordinate.
Y: y coordinate.
W: width.
H: height.
Flags: Flags of the control. Flags must be separated with the symbol "|".
ExFlags: extended flags of the control. Flags must be separated with the symbol "|".

 

Flags

 

This control supports the Window Styles and you can specify any of the styles listed below:

 

LVS_ALIGNLEFT Items are left-aligned in icon and small icon view.

LVS_ALIGNMASK The control’s current alignment.

LVS_ALIGNTOP Items are aligned with the top of the list-view control in icon and small icon view.

LVS_AUTOARRANGE Icons are automatically kept arranged in icon and small icon view.

LVS_EDITLABELS Item text can be edited in place.

LVS_ICON This style specifies icon view.

LVS_LIST This style specifies list view.

LVS_NOCOLUMNHEADER Column headers are not displayed in report view. By default, columns have headers in report view.

LVS_NOLABELWRAP Item text is displayed on a single line in icon view. By default, item text may wrap in icon view.

LVS_NOSCROLL Scrolling is disabled. All items must be within the client area. This style is not compatible with the LVS_LIST or LVS_REPORT styles.

LVS_NOSORTHEADER Column headers do not work like buttons. This style can be used if clicking a column header in report view does not carry out an action, such as sorting.

LVS_OWNERDATA This style specifies a virtual list-view control.

LVS_OWNERDRAWFIXED The owner window can paint items in report view.

LVS_REPORT This style specifies report view. When using the LVS_REPORT style with a list-view control, the first column is always left-aligned.

LVS_SHAREIMAGELISTS The image list will not be deleted when the control is destroyed. This style enables the use of the same image lists with multiple list-view controls.

LVS_SHOWSELALWAYS The selection, if any, is always shown, even if the control does not have the focus.

LVS_SINGLESEL Only one item at a time can be selected. By default, multiple items may be selected.

LVS_SMALLICON This style specifies small icon view.

LVS_SORTASCENDING Item indexes are sorted based on item text in ascending order.

LVS_SORTDESCENDING Item indexes are sorted based on item text in descending order.

LVS_TYPEMASK Determines the control’s current window style.

LVS_TYPESTYLEMASK Determines the window styles that control item alignment and header appearance and behavior.

 

Extended Flags

 

This control supports the Extended Window Styles.

 

Return Value

 

If the function succeeds, the return value is a handle to the new list-view control.

If the function fails, the return value is false.

To get extended error information, call api_control_get_last_error().

 

Control Functions

 

api_listview_set_exstyle(ListViewHandle, ListViewExStyle) Sets extended styles in list-view controls.

ListViewHandle: it must be a ListViewHandle.
ListViewExStyle: value that specifies the extended list-view control styles to set.

ListViewExStyle argument can be a combination of the following flags:

LVS_EX_AUTOAUTOARRANGE Automatically arrange icons if no icon positions have been set (Similar to LVS_AUTOARRANGE).

LVS_EX_AUTOCHECKSELECT Automatically select check boxes on single click.

LVS_EX_AUTOSIZECOLUMNS Automatically size listview columns.

LVS_EX_BORDERSELECT Changes border color when an item is selected, instead of highlighting the item.

LVS_EX_CHECKBOXES 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. 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.

LVS_EX_COLUMNOVERFLOW Indicates that an overflow button should be displayed in icon/tile view if there is not enough client width to display the complete set of header items. The list-view control sends a notification when the overflow button is clicked. This flag is only valid when LVS_EX_HEADERINALLVIEWS is also specified.

LVS_EX_COLUMNSNAPPOINTS Snap to minimum column width when the user resizes a column.

LVS_EX_DOUBLEBUFFER Paints via double-buffering, which reduces flicker. This extended style also enables alpha-blended marquee selection on systems where it is supported.

LVS_EX_FLATSB Enables flat scroll bars in the list view.

LVS_EX_FULLROWSELECT When an item is selected, the item and all its subitems are highlighted. This style is available only in conjunction with the LVS_REPORT style.

LVS_EX_GRIDLINES Displays gridlines around items and subitems. This style is available only in conjunction with the LVS_REPORT style.

LVS_EX_HEADERDRAGDROP Enables drag-and-drop reordering of columns in a list-view control. This style is only available to list-view controls that use the LVS_REPORT style.

LVS_EX_HEADERINALLVIEWS Show column headers in all view modes.

LVS_EX_HIDELABELS Hides the labels in icon and small icon view.

LVS_EX_INFOTIP When a list-view control uses the LVS_EX_INFOTIP style, a notification code is sent to the parent window before displaying an item’s tooltip.

LVS_EX_JUSTIFYCOLUMNS Icons are lined up in columns that use up the whole view.

LVS_EX_LABELTIP If a partially hidden label in any list view mode lacks tooltip text, the list-view control will unfold the label. If this style is not set, the list-view control will unfold partly hidden labels only for the large icon mode.

LVS_EX_MULTIWORKAREAS If the list-view control has the LVS_AUTOARRANGE style, the control will not autoarrange its icons until one or more work areas are defined. To be effective, this style must be set before any work areas are defined and any items have been added to the control.

LVS_EX_ONECLICKACTIVATE he list-view control sends a notification code to the parent window when the user clicks an item. This style also enables hot tracking in the list-view control. Hot tracking means that when the cursor moves over an item, it is highlighted but not selected.

LVS_EX_REGIONAL Any area that is not part of an item is excluded from the window region. This style is only available to list-view controls that use the LVS_ICON style.

LVS_EX_SIMPLESELECT In icon view, moves the state image of the control to the top right of the large icon rendering. In views other than icon view there is no change. When the user changes the state by using the space bar, all selected items cycle over, not the item with the focus.

LVS_EX_SINGLEROW Not used.

LVS_EX_SNAPTOGRID n icon view, icons automatically snap into a grid.

LVS_EX_SUBITEMIMAGES Allows images to be displayed for subitems. This style is available only in conjunction with the LVS_REPORT style.

LVS_EX_TRACKSELECT Enables hot-track selection in a list-view control. Hot track selection means that an item is automatically selected when the cursor remains over the item for a certain period of time. This style applies to all styles of list-view control.

LVS_EX_TRANSPARENTBKGND Background is painted by the parent via WM_PRINTCLIENT.

LVS_EX_TRANSPARENTSHADOWTEXT Enable shadow text on transparent backgrounds only.

LVS_EX_TWOCLICKACTIVATE The list-view control sends a notification code to the parent window when the user double-clicks an item. This style also enables hot tracking in the list-view control. Hot tracking means that when the cursor moves over an item, it is highlighted but not selected.

LVS_EX_UNDERLINECOLD Causes those non-hot items that may be activated to be displayed with underlined text. This style requires that LVS_EX_TWOCLICKACTIVATE be set also.

LVS_EX_UNDERLINEHOT Causes those hot items that may be activated to be displayed with underlined text. This style requires that LVS_EX_ONECLICKACTIVATE or LVS_EX_TWOCLICKACTIVATE also be set.

 

api_listview_get_exstyle(ListViewHandle) Gets the extended styles that are currently in use for a given list-view control.

ListViewHandle: it must be a ListViewHandle.

 

api_listview_add_column(ListViewHandle, ColumnIndex,Width, ImageIndex, Text) Inserts a new column in a list-view control. Returns the index of the new column if successful, or -1 otherwise.

ListViewHandle: it must be a ListViewHandle.
ColumnIndex: zero-based index of the new column.
Width: width of the column, in pixels.
ImageIndex: zero-based index of an image within the image list.
Text: column header text.

 

api_listview_set_column_width(ListViewHandle, ColumnIndex, Width) Sets the width of a column in report-view mode or the width of all columns in list-view mode. This function returns true if successful, or false otherwise.

ListViewHandle: it must be a ListViewHandle.
ColumnIndex: zero-based index of the column.
Width: width of the column, in pixels.

For report-view mode, the following special values are supported for Width argument:

LVSCW_AUTOSIZE Automatically sizes the column.

LVSCW_AUTOSIZE_USEHEADER Automatically sizes the column to fit the header text. If you use this value with the last column, its width is set to fill the remaining width of the list-view control.

 

api_listview_get_column_width(ListViewHandle, ColumnIndex) Returns the width of a column in report view if successful or zero otherwise.

ListViewHandle: it must be a ListViewHandle.
ColumnIndex: zero-based index of the column.

 

api_listview_set_column_image_index(ListViewHandle, ColumnIndex, ImageIndex) Sets the index of an image within the image list. This function returns true if successful, or false otherwise.

ListViewHandle: it must be a ListViewHandle.
ColumnIndex: zero-based index of the column.
ImageIndex: zero-based index of an image within the image list.

 

api_listview_get_column_image_index(ListViewHandle, ColumnIndex) Returns the index of an image within the image list.

ListViewHandle: it must be a ListViewHandle.
ColumnIndex: zero-based index of the column.

 

api_listview_set_column_text(ListViewHandle, ColumnIndex, Text) Sets the column header text. This function returns true if successful, or false otherwise.

ListViewHandle: it must be a ListViewHandle.
ColumnIndex: zero-based index of the column.
Text: column header text.

 

pai_listview_get_column_text(ListViewHandle, ColumnIndex) Returns the column header text. This feature is limited to a maximum of 256 characters.

ListViewHandle: it must be a ListViewHandle.
ColumnIndex: zero-based index of the column.

 

api_listview_delete_column(ListViewHandle, ColumnIndex) Removes a column from a list-view control.

ListViewHandle: it must be a ListViewHandle.
ColumnIndex: zero-based index of the column.

 

api_listview_add_item(ListViewHandle, ItemIndex, ColumnIndex, ImageIndex, Text) Inserts a new item in a list-view control. You must always add the main item with ColumnIndex equals to 0 first, then you can add more subitems by incrementing that argument.

ListViewHandle: it must be a ListViewHandle.
ItemIndex: zero-based index of the new item.
ColumnIndex: zero-based index of the column.
ImageIndex: zero-based index of an image within the image list.
Text: text of the new item.

 

api_listview_set_item_image_index(ListViewHandle, ItemIndex, ColumnIndex, ImageIndex) Sets the index of an image within the image list.

ListViewHandle: it must be a ListViewHandle.
ItemIndex: zero-based index of the item.
ColumnIndex: zero-based index of the column.
ImageIndex: zero-based index of an image within the image list.

 

api_listview_get_item_image_index(ListViewHandle, ItemIndex, ColumnIndex) Returns the index of an image within the image list.

ListViewHandle: it must be a ListViewHandle.
ItemIndex: zero-based index of the item.
ColumnIndex: zero-based index of the column.

 

api_listview_set_item_text(ListViewHandle, ItemIndex, ColumnIndex, Text) Sets the text of the specified item in a list-view control. This function returns true if successful, or false otherwise.

ListViewHandle: it must be a ListViewHandle.
ItemIndex: zero-based index of the item.
ColumnIndex: zero-based index of the column.
Text: text of the item.

 

api_listview_get_item_text(ListViewHandle, ItemIndex, ColumnIndex) Returns the text of the specified item in a list-view control. This feature is limited to a maximum of 256 characters.

ListViewHandle: it must be a ListViewHandle.
ItemIndex: zero-based index of the item.
ColumnIndex: zero-based index of the column.

 

api_listview_set_item_selection(ListViewHandle, ItemIndex, Selected) Sets the current selection state of the specified item in a list-view control.

ListViewHandle: it must be a ListViewHandle.
ItemIndex: zero-based index of the item.
Selected: selects (true) or deselects (false) the specified item.

 

api_listview_get_item_selection(ListViewHandle, ItemIndex) Returns true if the specified item is selected or false otherwise.

ListViewHandle: it must be a ListViewHandle.
ItemIndex: zero-based index of the item.

 

api_listview_get_item_selection_count(ListViewHandle) Returns the number of selected items in a list-view control.

ListViewHandle: it must be a ListViewHandle.

 

api_listview_get_item_count(ListViewHandle) Returns the total number of items in a list-view control.

ListViewHandle: it must be a ListViewHandle.

 

api_listview_delete_item(ListViewHandle, ItemIndex) Removes an item from a list-view control. This function returns true if successful, or false otherwise.

ListViewHandle: it must be a ListViewHandle.
ItemIndex: zero-based index of the item.

 

api_listview_reset_items(ListViewHandle) Removes all items from a list view control and returns true if successful, or false otherwise.

ListViewHandle: it must be a ListViewHandle.

 

api_listview_set_imagelist(ListViewHandle, ImageListHandle, ImageType) Assigns an image list to a list-view control. This function returns the handle to the image list previously associated with the control if successful, or false otherwise.

ListViewHandle: it must be a ListViewHandle.
ImageListHandle: it must be an ImageListHandle.
ImageType: type of image list.

ImageType argument can be one of the following flags:

LVSIL_NORMAL Image list with large icons.

LVSIL_SMALL Image list with small icons.

LVSIL_STATE Image list with state images.

LVSIL_GROUPHEADER Image list for group header.

 

api_listview_get_imagelist(ListViewHandle, ImageType) Returns the handle to the specified image list if successful, or false otherwise.

ListViewHandle: it must be a ListViewHandle.
ImageType: type of image list.

ImageType argument can be one of the following flags:

LVSIL_NORMAL Image list with large icons.

LVSIL_SMALL Image list with small icons.

LVSIL_STATE Image list with state images.

LVSIL_GROUPHEADER Image list for group header.

 

api_listview_set_tooltip(ListViewHandle,TooltipHandle) Sets the tooltip control that the list-view control will use to display tooltips.

ListViewHandle: it must be a ListViewHandle.
TooltipHandle: it must be a TooltipHandle.

 

api_listview_get_tooltip(ListViewHandle) Returns the tooltip control that the list-view control will use to display tooltips.

ListViewHandle: it must be a ListViewHandle.

 

Code Examples

 

Creating a List-View Control

 

listview = api_listview_create(window,10,10,250,160,WS_VISIBLE | WS_CHILD | LVS_REPORT,WS_EX_CLIENTEDGE);

 

Setting Custom Extended Styles

 

api_listview_set_exstyle(listview,LVS_EX_FULLROWSELECT);

 

Adding Columns and Items

 

api_listview_add_column(listview,0,100,-1,"Column 1");
api_listview_add_column(listview,1,100,-1,"Column 2");
api_listview_add_item(listview,0,0,-1,"1");
api_listview_add_item(listview,0,1,-1,"Item 1");
api_listview_add_item(listview,1,0,-1,"2");
api_listview_add_item(listview,1,1,-1,"Item 2");
api_listview_add_item(listview,2,0,-1,"3");
api_listview_add_item(listview,2,1,-1,"Item 3");

 

I am Luigi Piscopo, also known as DJ GiDeejay / Producer / Remixer in the music world. I am a Producer with a lot of experience in photo editing, video editing, audio editing, graphic design, web design, programming and promotion.

Leave a Reply

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

*