Jump to content

Recommended Posts

Posted

What a co-inkydink, I made my first ever listliew this morning.

Unfortunately because of this I know very little regarding what they are capable of and potential, so I cant offer any feedback.

Suffice to say that all the examples work fine, dragging the about etc..

Cheers, I'll be looking more at this once I realize more what I can do in my project.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted (edited)

That's really nice. I was just thinking it would also be nice to be able to drag multiple selections all in one hit. Perhaps that could get complicated, but it was just a thought. I'll most likely find a use for this. Great!

Edited by czardas
Posted (edited)

This looks really useful for people like me who hate working with GUI crap :)

However, there's a problem with the code though - it doesn't work correctly in x64 mode, even after fixing the NMHDR struct (which should be:)

Local $tagNMHDR = DllStructCreate("hwnd;uint_ptr;int;int", $lParam) ; NMHDR + 1st element of NMLISTVIEW

The 4th element (which is actually part of NMLISTVIEW), should be the item 'index', but always returns 0 in x64 mode. Unfortunately this results in the 1st item in the list being moved, but not the dragged one. Very odd. I haven't seen anything yet indicating why it has this behavior.. still works fine in x86 mode of course. (This is on Win 7 x64)

Edited by Ascend4nt
  • Moderators
Posted

Ascend4nt,

I do not have access to an x64 system, so if you could determine what is going wrong I would be happy to amend the code. :)

This x64/x86 problem seems to raise its head more and more frequently as soon as you start getting into structs. We need someone to offer a tutorial - would you be ready to take it on? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

Okay, I figured it out. Funky thing that Windows has done here - they added a little 'buffer' between the end of the NMHDR structure and the next element in the NMLISTVIEW structure, and didn't tell anyone about it! Microsoft deserves a nice smack in the face for this.

Anyway, I've modified your function Melba23 to read as follows:

Func _GUIListViewEx_WM_NOTIFY_Handler($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg, $wParam

    Local $tagNMHDR = "hwnd;uint_ptr;int", $sBuf=''
    If @AutoItX64 Then $sBuf=';int'
    Local $tagNMLISTVIEW = $tagNMHDR & $sBuf & ";int Item;int SubItem;uint NewState;uint OldState;uint Changed;long X;long Y;lparam lParam"
    Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam), $tListView
    If @error Then Return

    Switch DllStructGetData($tNMHDR, 3)
        Case -2, $LVN_COLUMNCLICK ; -2 = $NM_CLICK

            ; Check if enabled ListView
            For $i = 1 To $aLVEx_Data[0][0]
                If DllStructGetData($tNMHDR, 1) = $aLVEx_Data[$i][0] Then
                    ExitLoop
                EndIf
            Next
            If $i > $aLVEx_Data[0][0] Then Return ; Not enabled

            ; Set values for active ListView
            $aLVEx_Data[0][1] = $i
            $hGLVEx_Handle = $aLVEx_Data[$i][0]
            $hGLVEx_CID = $aLVEx_Data[$i][1]
            $aLVEx_Array = $aLVEx_Data[$i][2]

        Case $LVN_BEGINDRAG
            ; Check if registered ListView
            For $i = 1 To $aLVEx_Data[0][0]
                If DllStructGetData($tNMHDR, 1) = $aLVEx_Data[$i][0] Then
                    ExitLoop
                EndIf
            Next
            If $i > $aLVEx_Data[0][0] Then Return ; Not registered

            ; Set values for ListView
            $aLVEx_Data[0][1] = $i
            $hGLVEx_Handle = $aLVEx_Data[$i][0]
            $hGLVEx_CID = $aLVEx_Data[$i][1]
            ; Copy array for manipulation
            $aLVEx_Array = $aLVEx_Data[$i][2]

            ; Check if Native or UDF and set focus
            If $hGLVEx_CID Then
                GUICtrlSetState($hGLVEx_CID, 256) ; $GUI_FOCUS
            Else
                _WinAPI_SetFocus($hGLVEx_Handle)
            EndIf

            $tListView=DllStructCreate($tagNMLISTVIEW, $lParam)
#cs
            ConsoleWrite("ListView items: Item: "& DllStructGetData($tListView,'Item')& _
                ", SubItem: "&DllStructGetData($tListView,'SubItem')& _
                ", NewState: "&DllStructGetData($tListView,'NewState')& _
                ", OldState: "&DllStructGetData($tListView,'OldState')& _
                ", Changed: "&DllStructGetData($tListView,'Changed')& _
                ", X: "&DllStructGetData($tListView,'X')& _
                ", Y: "&DllStructGetData($tListView,'Y')& _
                ", lParam: "&DllStructGetData($tListView,'lParam')& @LF)
#ce
            ; Store index of dragged item
            $iLVEx_Dragged_Index = DllStructGetData($tListView, 'Item') ; Item

            ; Set flag
            $fLVEx_Dragging = True
            ; Remove highlighting from item
            _GUICtrlListView_SetItemSelected($hGLVEx_Handle, $iLVEx_Dragged_Index, False)
    EndSwitch

EndFunc   ;==>_GUIListViewEx_WM_NOTIFY_Handler

I've filled in the whole NMLISTVIEW structure for you, which provides additional information that may or may not be of interest to you. In testing on Win7 x64, all the elements are returning fine (per the ConsoleWrite() I inserted).

You can of course remove all the extra info and modifications I made, but you'll need to retain that buffer for x64 systems, and then pull the 'Item' element by name rather than number.

If anyone is running Vista x64, I'd like to confirm that the above altered function works on that O/S as well, as I don't currently have a build to test that on (I'm assuming its an x64 issue, but there's always a chance that its a Win7 x64 issue, I suppose)

Oh, and Melba23 - sorry, no tutorial from me lol. For the most part, stick to the structure datatypes found on MSDN and you'll be fine (this is one exception however where its not the case). Also, Jon did a thread on this ->

Posted (edited)

Melba, hmm.. seems I should have realized this earlier - the NMHDR is where there's an issue. The third element should be 'int_ptr'.

The problem with that, and what initially threw me, is the negative numbers in the Case statement would have to be positive since int_ptr is a 64-bit value, and the negative numbers refer to a 32-bit-sized integer. But we can force them to be negative with BitAND..

So all that needs to be done really is this:

Local $tagNMHDR = DllStructCreate("hwnd;uint_ptr;int_ptr;int", $lParam)

and to make it a signed 32-bit number, this:

Switch BitAND(DllStructGetData($tNMHDR, 3), 0xFFFFFFFF)

Change those two lines, and your UDF is fixed. One interesting thing though - the NMLISTVIEW structure will tell you the SubItem you are 'moving'. Not sure if that actually can be used tor any good though, since moving just sub-items would be a bit more complex and confusing.

*edit: oops, forgot 4th element

Edited by Ascend4nt
  • Moderators
Posted (edited)

Ascend4nt,

Thank you for that. :)

I do take exception to the "fixed" bit though - I woudl have preferred "x64 compatible". ;)

Pity about the tutorial though. :idiot:

M23

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • Moderators
Posted

NEW VERSION - 3 Feb 11

Improvements:

- Now x64 compatible (thanks Ascend4nt :))

- Now drags blocks of selected items and deletes all selected items (you can thank czardas for that as he asked for it ;))

New UDF and zip in first post

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

Nice Example. Plus its good to see the x64 issue with $tagNMHDR has been rectified in this version. I am a little bit reluctant to start changing the ListView includes to work with x64!

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Posted

Good work Melba. Just curious - is the multiple-item-move supposed to work with contiguous selected items only? Only reason I ask is because doing multiple selection using 'Ctrl-click' works only when the items are bunched together - any other items selected remain where they were.

For example, if items #1-3 and item #6 selected, then dragged. Only items 1-3 will be moved. Item #6 stays in the same spot.

Otherwise - very nice job. One day I might use it.. though I think I stopped futzing around with ListViews because I wanted 'sort' and 'insert-into-sorted' list functions, but was too lazy to do the work :)

Posted

I also considered the idea of dragging gapped selections, but it's not clear to me how it should work or why it is needed. I can think of two viable alternatives: either you queue the items that are not selected and insert them between the gaps, or you could collapse the gaps in the selection during the drag. While dragging a contiguous selection in one hit can save a lot of time, I don't see the same benefit with a non-continguous selection, except under very rare circumstances. Although, it would be a pretty neat trick. :)

Posted (edited)

I have a request... GUITreeViewEx ;) Don't stop typing Melba, you are way too valuable :)

Mat

Edit: And use [hr] rather than ###### to seperate your post. It messes up the forum when you have a very long line.

Edited by Mat
  • Moderators
Posted (edited)

Ascend4nt,

You are correct - it will only move a consecutive block of selections - although you can drag any of the items within the section to move it. I could not think of a sensible logic to move the other selected items as well. And anyway it looked as if any solution would require far too much coding! :idiot:

Mat,

GUITreeViewEx.....I will have to think about that one a bit. :)

Edit: No need - take a look here.

Thanks for the separator tip - you will see it is now implemented. ;)

M23

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (edited)

Got a few errors

In "LVEx_Example_1.au3"

These steps are repeatable: (or maybe not? :) )

1. Drag a few list view items (on the first listview)
2. Click elsewhere on the GUI a couple of times (not a button or listview)
* Column 0 text disapears
* Console says
-- Inserting at LV Index: 10 
-- Inserting at LV Index: 11
--etc
4. Drag a few more items a couple times
5. ...
(944) : ==> Variable used without being declared.:
_GUIListViewEx_Array_Insert($aLVEx_Array, $iGLVExInsert_Index + 1, $aInsertData[$i])
_GUIListViewEx_Array_Insert($aLVEx_Array, $iGLVExInsert_Index + 1, ^ ERROR

Tried this with the second list view and Steps 1 and 2 follow immediatly with an hardcrash error

I also got these errors but I don't recall what I did to cause them

==> Subscript used with non-Array variable.:
_GUICtrlListView_SetItemText($hGLVEx_Handle, $i, $aLVEx_Array[$i + 1])
_GUICtrlListView_SetItemText($hGLVEx_Handle, $i, $aLVEx_Array^ ERROR

==> Array variable subscript badly formatted.:
Local $aInsertData[$iMultipleItems + 1]
Local $aInsertData[^ ERROR

Windows XP SP3, AutoIt 3.3.6.0

[Edit: No hard crash :P]

Edited by WeMartiansAreFriendly
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
  • Moderators
Posted

WeMartiansAreFriendly,

Thank you for that - I can reproduce them all and I know what the problem is. :idiot:

I somehow missed a check line in one of the message handlers so it reacted all the time and not just when dragging. ;)

New UDF and zip in first post. Thanks again. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • 4 weeks later...
Posted

I've been getting this error when dragging items.

C:\Program Files (x86)\AutoIt3\Include\GuiListViewEx.au3 (954) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$aItemData[$i] = $aGLVEx_Array[$iGLVExDragged_Index + 1][$i]

$aItemData[$i] = ^ ERROR

I'm not sure if I'm missing something or not, but I'm using the UDF Listview with these lines

$ListView3_Index = _GUIListViewEx_Init($ListView3, "", 0, 0x00FF00)

_GUIListViewEx_DragRegister()

Should I set an active Listview since I have 3?

  • Moderators
Posted

strikeraid,

I need more code than that to give you a sensible answer - I would suggest posting the whole script. ;)

When you post your code please use Code tags. Put [autoit] before and [/autoit] after your posted code. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

Nevermind. I figured it was because I didn't declare an array in

$ListView3_Index = _GUIListViewEx_Init($ListView3, "", 0, 0x00FF00)

The program adds items to a listview so I don't have an array that is put into the listview. I'll just forget about dragging.

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...