AHK version: 1.1.23.01
This class provides an easy way to add functionalities to ListViews that are not supported by AutoHotkey built-in functions such as Copy, Cut, Paste, Drag and more.
LV_EX functions by just me
- Copy()
- Cut()
- Paste([Row, Multiline])
- Duplicate()
- Delete()
- Move([Up])
- Drag([DragButton, AutoScroll, ScrollDelay, LineThick, Color])
- Add()
- Undo()
- Redo()
- ClearHistory()
- EnableGroups([Enable, FirstName, Collapsible, StartCollapsed])
- InsertGroup([Row, GroupName])
- RemoveGroup([Row])
- InsertAtGroup([Count, Rows*])
- RemoveAtGroup([Count, Rows*])
- SetGroups(Groups)
- GetGroups([AsObject])
- SetGroupCollapisable([Collapsible])
- RemoveAllGroups([FirstName])
- CollapseAll([Collapse])
- RefreshGroups([Collapsed])
- InsertHwnd(Hwnd)
- RemoveHwnd(Hwnd)
- SetHwnd(Hwnd [, NewData])
- GetData([Hwnd])
- SetCallback(Func)
You can call the function by preceding them with LV_Rows. For example: LV_Rows.Copy() <-- Calls function on active ListView.
Or with a handle initialized via New meta-function. For example: MyListHandle := New LV_Rows() <-- Creates a new handle. MyListHandle.Add() <-- Calls function for that Handle.
Like AutoHotkey built-in functions, these functions operate on the default gui, and active ListView control. When usingle handles, SetHwnd will attempt to set the selected ListView as active, but it's recommend to call Gui, Listview on your script too.
Initializing is required for History and Group functions and in case your ListView has icons to be moved during Drag(). Gui, Add, ListView, hwndhLV, Columns MyListHandle := New LV_Rows(hLV) <-- Creates a new handle with Hwnd.
Gui, Add, ListView, hwndhLV1, Columns Gui, Add, ListView, hwndhLV2, Columns MyListHandle := New LV_Rows(hLV1, hLV2)
You can also use the same handle for the Edit functions. You can create more handles or pass the ListView's Hwnd to operate on different lists with the same handle.
In order to keep row's icons you need to initialize the class passing the ListView's Hwnd. For example: Gui, Add, ListView, hwndhLV, Columns MyListHandle := New LV_Rows(hLV)
Set, Insert and Remove ListView Hwnd's.
Inserts one or more ListView Hwnd's to be managed.
No return value.
- Hwnd - One or more ListView Hwnd's.
Removes a ListView Hwnd.
No return value.
- Hwnd - Hwnd of the ListView to be removed.
Selects a previously inserted ListView or adds it to the handle and selects it, optionally copying the data, history and groups from another Hwnd.
No return value.
- Hwnd - Hwnd of a ListView to be selected. If the hwnd is not found, it will be added to the handle and selected.
- NewData - Hwnd of a previously inserted ListView whose data, history and groups will be copied to the one being selected.
Retrieves the data, history and groups of a previously inserted ListView.
An object with data, history and groups of a ListView.
- Hwnd - Hwnd of a previously inserted ListView. If left blank, the current active ListView will be returned.
Sets a callback function where the user can take actions based on the function being called called. The Callback function must return true for the operation to be completed.
No return value.
- Func - Name of a user-defined function that should receive 2 parameters** - The name of the function being called and the Hwnd of the current set ListView.
Edit ListView rows.
Copy selected rows to memory.
Number of copied rows.
Copy selected rows to memory and delete them.
Number of copied rows.
Paste copied rows at selected position.
True if memory contains data or false if not.
- Row - If non-zero pastes memory contents at the specified row.
- Multiline - If true pastes the contents at every selected row.
Duplicates selected rows.
Number of duplicated rows.
Delete selected rows.
Number of removed rows.
Move selected rows down or up.
Number of rows moved.
- Up - If false or omitted moves rows down. If true moves rows up.
Drag-and-Drop selected rows showing a destination bar. Must be called in the ListView G-Label subroutine when A_GuiEvent returns "D" or "d".
The destination row number.
- DragButton - If it is a lower case "d" it will be recognized as a Right-Click drag and won't actually move any row, only return the destination, otherwise it will be recognized as a Left-Click drag. You may pass A_GuiEvent as the parameter.
- AutoScroll - If true or omitted the ListView will automatically scroll up or down when the cursor is above or below the control.
- ScrollDelay - Delay in miliseconds for AutoScroll. Default is 100ms.
- LineThick - Thickness of the destination bar in pixels. Default is 2px.
- Color - Color of destination bar. Default is "Black".
Keep a history of ListView changes and allow Undo and Redo. These functions operate on the currently selected ListView.
Adds an entry on History. This function requires initializing: MyListHandle := New LV_Rows()
The total number of entries in history.
Replaces ListView contents with previous entry state, if any.
New entry position or false if it's already the first entry.
Replaces ListView contents with next entry state, if any.
New entry position or false if it's already the last entry.
Removes all history entries from the ListView.
New entry position or false if it's already the last entry.
Set, add and remove Listview Groups. These functions are based on just me's LV_EX library
Enables or disables Groups in the currently selected ListView initializing: MyListHandle := New LV_Rows()
No return value.
- Enable - If TRUE enables GroupView in the selected ListView. If FALSE disables it.
- FirstName - Name for the first (mandatory) group at row 1.
- Collapsible - If TRUE makes the groups collapsible.
- StartCollapsed - If TRUE starts all groups collapsed.
Inserts or renames a group on top of the specified row.
TRUE if Row is bigger than 0 or FALSE otherwise.
- Row - Number of the row for the group to be inserted. If left blank the first selected row will be used.
- GroupName - Name of the new group or new name for an existing group.
Removes the group the indicated row belongs to.
TRUE if Row is bigger than 0 or FALSE otherwise.
- Row - Number of a row the group belongs to. If left blank the first selected row will be used.
Inserts a row at indicated position, moving groups after it one row down.
No return value.
- Row - Number of the row where to insert.
Removes a row from indicated position, moving groups after it one row up.
No return value.
- Row - Number of the row where to insert.
Sets one or more groups in the selected ListView.
No return value.
- Groups - A list of groups in the format "GroupName:RowNumber" separated by comma. You can use GetGroups() to save a valid String or Object to be used with this function.
Returns a string or object representing the current groups in the selected ListView.
No return value.
- AsObject - If TRUE returns an object with the groups, otherwise an string. Both can be used with SetGroups().
Enables or disables Groups Collapsible style.
No return value.
- Collapsible - If TRUE enables Collapsible style in the selected ListView. If FALSE disables it.
Removes all groups in the selected ListView.
No return value.
- FirstName - Name for the first (mandatory) group at row 1.
Collapses or expands all groups.
No return value.
- Collapse - If TRUE collapses all groups in the selected ListView. If FALSE expands all groups in the selected ListView.
Reloads the ListView to update groups. This function is called automatically in from other functions, usually it's not necessary to use it in your script.
No return value.
- Collapsed - If TRUE collapses all groups in the selected ListView.