Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[Class] LV_Rows - Copy, Cut, Paste and Drag ListViews


  • Please log in to reply
18 replies to this topic
Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012
Updated 17-06-2013: Added support for ListViews with icons.
Updated 27-08-2013: Added Multiline-Paste option; Added support Duplicate function.
Updated 12-09-2013: Fixed wrong line width on systems with a non-standard DPI setting.
 
This class is a collection of functions to allow additional functionalities in ListViews that are not supported by AutoHotkey built-in functions.
It provides an easy way to add the commands Copy, Cut, Paste, DuplicateDelete, Move, Drag, Undo and Redo.

Features:
  • Edit functions: Copy, Cut, Paste, Duplicate, Delete, Move and Drag-and-Drop.
  • History functions: Add, Undo and Redo.
  • Copy, cut and paste between different ListViews.
  • Keep history of individual ListViews to be used with Undo and Redo.
  • Drag-and-Drop shows a destination bar to indicate where selected rows will be moved to.
  • Auto-Scrolls ListViews when dragging above or below them.
  • Supports Right-Click drag.
  • Supports Checked ListViews.
  • Supports ListViews with Icons.
  • Customize Auto-Scroll delay, thickness and color of destination bar.
Screenshots:
Spoiler

Class_LV_Rows.ahk
Spoiler

Notes:
  • They all operate on the active ListView control, like AHK built-in functions.
  • Edit functions can be called directly as easy as ^c::LV_Rows.Copy().
  • History functions must be initialized via Handle := New LV_Rows().
  • To keep original icons you must initialize it passing the ListView's HWND, i.e. Handle := New LV_Rows(Hwnd).
  • The Drag function must be called from the LV G-Label when the Drag event occurs.
  • You can keep individual Copy & Paste data by using different handles.
The examples below should illustrate usage better.
LV_Rows_Demo.ahk:
Spoiler

LV_Rows_IconsDemo.ahk:

I've originally written this class to use with my Macro Creator. Suggestions of improvements are welcome.
Special thanks to Micahs for the base code for the Drag function.

Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


Verdlin
  • Members
  • 256 posts
  • Last active: Apr 29 2016 06:46 PM
  • Joined: 21 Dec 2012

Wow. I definitely want to use this! Like you, I use LV_Colors, as well. What I really want to see is those two classes merged together. That would make using both more efficient and easier.


Scripts are written and tested using AHK_H 64w (unless otherwise specified).

CFlyout. EasyIni. Dynamic Label Execution (No Reload). Word Lookup.


Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012
Thank you Verdlin. Just me's classes are very impressive. I haven't tried but I suppose it would be possible to merge them. Easier way would be to copy the functions from this one to his, and insert the contents from __New there too. Of course this could raise some problems, but if it would be useful for you why don't you try?

Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


Verdlin
  • Members
  • 256 posts
  • Last active: Apr 29 2016 06:46 PM
  • Joined: 21 Dec 2012

That sounds like a good idea. I'll work on merging the two. If I make good progress, I'll let you know. Thanks!


Scripts are written and tested using AHK_H 64w (unless otherwise specified).

CFlyout. EasyIni. Dynamic Label Execution (No Reload). Word Lookup.


guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011
awesome work

Alpha Bravo
  • Members
  • 1687 posts
  • Last active: Nov 07 2015 03:06 PM
  • Joined: 01 Sep 2011

very nice



Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012
Update

I had forgotten about my nasty trick to check if the project has changed. I've updated the Class with a more convenient method.

If you use a handle (by initializing it with Handle := New LV_Rows()) the HasChanged property will be set to True everytime a function is called (except Copy), so you may consult Handle.HasChanged to optionally show a save dialog in your program, then set it back to False after saving.



awesome work

 

very nice


Thank you!

Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


Cattleya
  • Members
  • 90 posts
  • Last active: Sep 13 2013 05:11 AM
  • Joined: 28 Sep 2011

Hi Pulover,

Can you add a function that allow user edit list view(not only row 1 like Autohotkey default).

 

Like this function: http://www.autohotke...-for-listviews/



Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012

Hello Cattleya,

 

I don't know... just me's class is very complex so I suppose there isn't an easy way to do that. Do you have problems using both classes?

 

I'm currently trying to get the icon index from a row in order to move icons too. When (or if) I get this done I will look around to see if I can find a way to do that, but I doubt I'll get a better solution then the InCellEdit class.


Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012

Update

 

After searching a lot and learning about structures I was finally able to create a function to retrieve the row's icon index.

 

The class now supports ListView with icons, by passing the ListView control's HWND when initializing a new class It'll keep each row's original icon in all operations.

 

I've added another example with icons.


Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


faqbot
  • Members
  • 997 posts
  • Last active:
  • Joined: 10 Apr 2012

The class now supports ListView with icons, by passing the ListView control's HWND when initializing a new class It'll keep each row's original icon in all operations. I've added another example with icons.

 

Thanks I was waiting for that as well !



Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012

Update

  • Added Multiline option to Paste function.
  • Added Duplicate function.

 

Multiline means that if more then one row is selected the Paste function will paste the contents on top of each one. You can disable this in the parameters.

 

Edit: Changed the Multiline option to Disabled by default.


Edited by Pulover, 29 August 2013 - 12:28 AM.

Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


skurdt
  • Members
  • 6 posts
  • Last active: Jan 25 2014 12:28 AM
  • Joined: 25 Aug 2012

This class is really great man, I've got a bunch of listviews on my current project and this is a godsend, so thanks a lot :)

 

About the multiline option, shouldn't it be disabled by default?

I mean, if for some reason there are more than 1 row selected or if using copy & paste to "simulate" the duplicate function (basically you still have all your rows selected), the paste behavior doesn't feel natural to me.

Of course you can disable it, but as it sounds like a rather specific thing one would want, it would seem logical to pass functions parameters only if you want it.



Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012

This class is really great man, I've got a bunch of listviews on my current project and this is a godsend, so thanks a lot happy.png

Nice to hear that!
 

About the multiline option, shouldn't it be disabled by default?
I mean, if for some reason there are more than 1 row selected or if using copy & paste to "simulate" the duplicate function (basically you still have all your rows selected), the paste behavior doesn't feel natural to me.
Of course you can disable it, but as it sounds like a rather specific thing one would want, it would seem logical to pass functions parameters only if you want it.

Well, my thought was that we usually have one row selected when we paste so if more then one is selected and multi-paste is done by accident we can just undo... But I'm always willing to hear other opinions, and thinking about the simulated duplicated function you mentioned I guess it makes more sense to make it disabled by default. I have edited the gist.

 

Thanks for the feedback and suggestion!


Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


okram
  • Members
  • 230 posts
  • Last active: Oct 15 2015 05:55 AM
  • Joined: 05 Oct 2012

This is AWSOME!!! Thank you so much!