Verssuss Posted May 29, 2017 Share Posted May 29, 2017 Hello. The case is complicated as if otherwise ... I'm going to add a parameter or an independent variable (assigned forever to the given item (not to the index)) I have some ideas but everything goes down when an item is drag & drop ... All what i want is add variable/param to choosen item and move it by any possible way with variable/param added before... I always move Item but it lost variable/param ;/ here is 2 way i try expandcollapse popup#AutoIt3Wrapper_UseX64=Y #include "GUIListViewEx.au3" #include <WindowsConstants.au3> #include <GUIListView.au3> #include <GUIImageList.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> HotKeySet("z", "_set_param") HotKeySet("x", "_show_params") $Main_GUI = GUICreate("Drag & Drop LV Item", 225, 400, -1, -1, BitOR($WS_THICKFRAME, $WS_SIZEBOX)) $ListView = GUICtrlCreateListView("Entry Name|Category", 5, 75, 195, 280, 0) $iLV_Index = _GUIListViewEx_Init($ListView, "", 0, 0, True, 1 + 2 + 8) _GUICtrlListView_SetExtendedListViewStyle($ListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) Global $vData, $iEditMode = 0 _GUIListViewEx_MsgRegister() For $i = 0 To 9 Global $vData[] = ["Item " & $i] _GUIListViewEx_Insert($vData) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $vRet = _GUIListViewEx_EventMonitor($iEditMode) WEnd Func _set_param() ; HOTKEY Z _GUICtrlListView_SetItemParam($Listview, _GUICtrlListView_GetSelectedIndices($Listview), 11111) EndFunc Func _show_params() ; HOTKEY X MsgBox($MB_SYSTEMMODAL, "Information", "Item 0 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 0)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 1 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 1)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 2)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 3 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 3)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 4 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 4)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 5 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 5)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 6 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 6)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 7 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 7)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 8 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 8)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 9 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 9)) EndFunc and another expandcollapse popup#include <WindowsConstants.au3> #include <GUIListView.au3> #include <GUIImageList.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> HotKeySet("z", "_set_param") HotKeySet("x", "_show_params") Global $iLast_Index = -1 Global $a_Index[2] ;From and to Global $iLastLineTop, $iLastLineLeft Global $iDragging = False Global $iDrawing = False ;To ensure mousemove doesn't cause more than one line to be drawn Global $iLButtonIsUp = False ;To ensure a correct redraw of ListView $Main_GUI = GUICreate("Drag & Drop LV Item", 225, 400, -1, -1, BitOR($WS_THICKFRAME, $WS_SIZEBOX)) $ListView = GUICtrlCreateListView("Entry Name|Category", 5, 75, 195, 280, 0) $h_ListView = GUICtrlGetHandle($ListView) $nExStyle = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $nExStyle, $nExStyle) For $i = 0 To 9 _GUICtrlListView_InsertItem($Listview, "Item " & $i, $i) Next GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY_EVENTS") GUIRegisterMsg($WM_LBUTTONUP, "WM_LBUTTONUP_EVENTS") GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE_EVENTS") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch If $iLButtonIsUp Then $iLButtonIsUp = False DllCall("User32.dll", "int", "RedrawWindow", "hwnd", $h_ListView, "ptr", 0, "int", 0, "int", 5) EndIf WEnd Func WM_LBUTTONUP_EVENTS($hWndGUI, $MsgID, $wParam, $lParam) If $iDragging = False Then Return $GUI_RUNDEFMSG $iLButtonIsUp = True $iDragging = False $iDrawing = False $iLast_Index = -1 Local $aLV_Pos = ControlGetPos($hWndGUI, "", $ListView) Local $iX = BitAND($lParam, 0xFFFF) - $aLV_Pos[0] Local $iY = BitShift($lParam, 16) - $aLV_Pos[1] Local $struct_LVHITTESTINFO = DllStructCreate("int;int;uint;int;int;int") DllStructSetData($struct_LVHITTESTINFO, 1, $iX) DllStructSetData($struct_LVHITTESTINFO, 2, $iY) $a_Index[1] = GUICtrlSendMsg($ListView, $LVM_HITTEST, 0, DllStructGetPtr($struct_LVHITTESTINFO)) Local $iFlags = DllStructGetData($struct_LVHITTESTINFO, 2) ;// Out of the ListView? If $a_Index[1] = -1 Then $a_Index[1] = _GUICtrlListView_GetItemCount($h_ListView) ;Return $GUI_RUNDEFMSG If $a_Index[0] < $a_Index[1] Then _GUICtrlListView_CopyItemsEx($h_ListView, $h_ListView, $a_Index[1], True) ElseIf $a_Index[0] > $a_Index[1] Then _GUICtrlListView_CopyItemsEx($h_ListView, $h_ListView, $a_Index[1], True,1) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_LBUTTONUP_EVENTS Func WM_MOUSEMOVE_EVENTS($hWndGUI, $MsgID, $wParam, $lParam) If Not $iDragging Or $iDrawing Then Return $GUI_RUNDEFMSG Local $aLV_Pos = ControlGetPos($hWndGUI, "", $ListView) Local $iX = BitAND($lParam, 0xFFFF) - $aLV_Pos[0] Local $iY = BitShift($lParam, 16) - $aLV_Pos[1] Local $struct_LVHITTESTINFO = DllStructCreate("int;int;uint;int;int;int") DllStructSetData($struct_LVHITTESTINFO, 1, $iX) DllStructSetData($struct_LVHITTESTINFO, 2, $iY) Local $iItem = GUICtrlSendMsg($ListView, $LVM_HITTEST, 0, DllStructGetPtr($struct_LVHITTESTINFO)) If $iItem = -1 Then $iItem = _GUICtrlListView_GetItemCount($h_ListView) ;Return $GUI_RUNDEFMSG If $iLast_Index = $iItem Then Return $GUI_RUNDEFMSG If $iLast_Index > $iItem Then ;Move up _GUICtrlListView_RedrawItems($h_ListView, $iItem, $iLast_Index) Else _GUICtrlListView_RedrawItems($h_ListView, $iLast_Index, $iItem - 1) EndIf $iLast_Index = $iItem Local $aLV_Pos = ControlGetPos($hWndGUI, "", $ListView) Local $iY = _GUICtrlListView_GetItemPositionY($h_ListView, $iItem) If $iY <= 0 Then Return $GUI_RUNDEFMSG _DrawLine($aLV_Pos[0], $iY, $aLV_Pos[2], 2.5, 0x000000, $h_ListView) EndFunc ;==>WM_MOUSEMOVE_EVENTS Func WM_NOTIFY_EVENTS($hWndGUI, $MsgID, $wParam, $lParam) Local $tagNMHDR, $iEvent, $hwndFrom, $iCode, $iItem $tagNMHDR = DllStructCreate("int;int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code, Item) If @error Then Return $GUI_RUNDEFMSG $iCode = DllStructGetData($tagNMHDR, 3) $iItem = DllStructGetData($tagNMHDR, 4) Switch $wParam Case $ListView Switch $iCode Case $LVN_BEGINDRAG $a_Index[0] = $iItem $iDragging = True EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY_EVENTS ;A try to make a multiple selection support for moved items Func _GUICtrlListView_CopyItemsEx($hWnd_Source, $hWnd_Destination, $iDstIndex, $fDelFlag = False,$ind_flag=0) Local $a_indices, $tItem = DllStructCreate($tagLVITEM), $iIndex, $movedInd = 0 Local $cols = _GUICtrlListView_GetColumnCount($hWnd_Source) Local $items = _GUICtrlListView_GetItemCount($hWnd_Source) _GUICtrlListView_BeginUpdate($hWnd_Source) _GUICtrlListView_BeginUpdate($hWnd_Destination) If BitAND(_GUICtrlListView_GetExtendedListViewStyle($hWnd_Source), $LVS_EX_CHECKBOXES) == $LVS_EX_CHECKBOXES Then For $i = 0 To $items - 1 If _GUICtrlListView_GetItemChecked($hWnd_Source, $i) Then If IsArray($a_indices) Then ReDim $a_indices[UBound($a_indices) + 1] Else Local $a_indices[2] EndIf $a_indices[0] = $a_indices[0] + 1 $a_indices[UBound($a_indices) - 1] = $i EndIf Next If UBound($a_indices) > 1 Then For $i = 1 To $a_indices[0] DllStructSetData($tItem, "Mask", BitOR($LVIF_GROUPID, $LVIF_IMAGE, $LVIF_INDENT, $LVIF_PARAM, $LVIF_STATE)) DllStructSetData($tItem, "Item", $a_indices[$i]+$movedInd*$ind_flag) DllStructSetData($tItem, "SubItem", 0) DllStructSetData($tItem, "StateMask", -1) _GUICtrlListView_GetItemEx($hWnd_Source, $tItem) $iIndex = _GUICtrlListView_InsertItem($hWnd_Destination, _ _GUICtrlListView_GetItemText($hWnd_Source, $a_indices[$i]+$movedInd*$ind_flag, 0), $iDstIndex, DllStructGetData($tItem, "Image")) _GUICtrlListView_SetItemChecked($hWnd_Destination, $iIndex) $iDstIndex += 1 $movedInd += 1 For $x = 1 To $cols - 1 DllStructSetData($tItem, "Item", $a_indices[$i]+$movedInd*$ind_flag) DllStructSetData($tItem, "SubItem", $x) _GUICtrlListView_GetItemEx($hWnd_Source, $tItem) _GUICtrlListView_AddSubItem($hWnd_Destination, $iIndex, _ _GUICtrlListView_GetItemText($hWnd_Source, $a_indices[$i]+$movedInd*$ind_flag, $x), $x, DllStructGetData($tItem, "Image")) Next _GUICtrlListView_SetItemSelected($hWnd_Source, $iIndex, True) $movedInd += 1 Next If $fDelFlag Then For $i = $a_indices[0] To 1 Step -1 _GUICtrlListView_DeleteItem($hWnd_Source, $a_indices[$i]) Next EndIf EndIf EndIf If _GUICtrlListView_GetSelectedCount($hWnd_Source) Then $a_indices = _GUICtrlListView_GetSelectedIndices($hWnd_Source, 1) For $i = 1 To $a_indices[0] $i_Index = $a_indices[$i]+$movedInd*$ind_flag DllStructSetData($tItem, "Mask", BitOR($LVIF_GROUPID, $LVIF_IMAGE, $LVIF_INDENT, $LVIF_PARAM, $LVIF_STATE)) DllStructSetData($tItem, "Item", $i_Index) DllStructSetData($tItem, "SubItem", 0) DllStructSetData($tItem, "StateMask", -1) _GUICtrlListView_GetItemEx($hWnd_Source, $tItem) $iIndex = _GUICtrlListView_InsertItem($hWnd_Destination, _ _GUICtrlListView_GetItemText($hWnd_Source, $i_Index, 0), $iDstIndex, DllStructGetData($tItem, "Image")) $iDstIndex += 1 $movedInd += 1 $i_Index = $a_indices[$i]+$movedInd*$ind_flag For $x = 1 To $cols - 1 DllStructSetData($tItem, "Item", $i_Index) DllStructSetData($tItem, "SubItem", $x) _GUICtrlListView_GetItemEx($hWnd_Source, $tItem) _GUICtrlListView_AddSubItem($hWnd_Destination, $iIndex, _ _GUICtrlListView_GetItemText($hWnd_Source, $i_Index, $x), $x, DllStructGetData($tItem, "Image")) Next _GUICtrlListView_SetItemSelected($hWnd_Source, $iIndex, True) Next If $fDelFlag Then For $i = $a_indices[0] To 1 Step -1 _GUICtrlListView_DeleteItem($hWnd_Source, $a_indices[$i]+$ind_flag*$a_indices[0]) Next EndIf EndIf _GUICtrlListView_EndUpdate($hWnd_Source) _GUICtrlListView_EndUpdate($hWnd_Destination) EndFunc Func _DrawLine($iLeft, $iTop, $iWidth, $iHeight, $sColor, $hWnd = 0) $iDrawing = True $sColor = Hex("0x" & BitAND(BitShift(String(Binary($sColor)), 8), 0xFFFFFF)) ;RGB2BGR Local $hDC = DllCall("User32.dll", "int", "GetDC", "hwnd", $hWnd) Local $aPen = DllCall("GDI32.dll", "int", "CreatePen", "int", 0, "int", $iHeight, "int", $sColor) DllCall("GDI32.dll", "int", "SelectObject", "int", $hDC[0], "int", $aPen[0]) If $iLastLineTop > -1 And $iLastLineLeft > -1 Then If $iLastLineTop <> $iTop Then $iLastLineLeft = $iLeft $iLastLineTop = $iTop DllCall("user32.dll", "int", "InvalidateRect", "hwnd", $hWnd, "int", 0, "int", 1) Sleep(10) ;seems to be needed to ensure redrawn before line is drawn EndIf EndIf DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hDC[0], "int", $iLeft, "int", $iTop, "int", 0) DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hDC[0], "int", $iLeft + $iWidth, "int", $iTop) DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hWnd, "int", $hDC[0]) DllCall("GDI32.dll", "int", "DeleteObject", "int", $aPen[0]) $iDrawing = False EndFunc ;==>_DrawLine Func _set_param() ; HOTKEY Z _GUICtrlListView_SetItemParam($Listview, _GUICtrlListView_GetSelectedIndices($Listview), 11111) EndFunc ;==>_quit Func _show_params() ; HOTKEY X MsgBox($MB_SYSTEMMODAL, "Information", "Item 0 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 0)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 1 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 1)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 2)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 3 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 3)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 4 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 4)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 5 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 5)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 6 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 6)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 7 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 7)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 8 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 8)) MsgBox($MB_SYSTEMMODAL, "Information", "Item 9 Parameter: " & _GUICtrlListView_GetItemParam($ListView, 9)) EndFunc Use the Z key to set parameter 11111 on the current item With the X key we read the parameters from all the items As I said when indexes 0,1,2 set this parameter, the reading is correct ... while the item is moved to another position, it simply loses part of the information ... This does not have to be a parameter. Any method is acceptable if it was not visible in the ListView, and the added value persisted after moving the item to another location. First example need Malba23's UDF GUIListViewEx.au3 Please help !!! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 29, 2017 Moderators Share Posted May 29, 2017 Verssuss, When using native-created ListViews, AutoIt uses the item parameter to store the ControlID of the row - so playing with this value is not a good idea. If you want to associate a value with a certain entry, I suggest you create a hidden (or zero-width) column to store this additional data - I have found that to be a very good method in the past. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Verssuss Posted May 29, 2017 Author Share Posted May 29, 2017 sure i already tested that and its low skilled option even each single action on yours 'hidden' box gonna shows again and ANYWAY i have to do to many column for that coz i need lot of variables. or u show they way to do it on strings ( like separate it ) to keep it in just one column im sure also there is a way to do it right. im not that pro to get fun at 3D variables or something but im sure its possible Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 29, 2017 Moderators Share Posted May 29, 2017 Verssuss, Quote im sure also there is a way to do it right Fine, good luck with your search. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
mikell Posted May 29, 2017 Share Posted May 29, 2017 @Melba23 There are none so deaf as he that will not hear Link to comment Share on other sites More sharing options...
Verssuss Posted May 29, 2017 Author Share Posted May 29, 2017 so there is the way to permanent hide any column ? even i have 5 of this ? show me plz the right way then Link to comment Share on other sites More sharing options...
mikell Posted May 30, 2017 Share Posted May 30, 2017 Nothing more than what Melba already said Create the column and set it permanently to zero-width using _GUICtrlListView_SetColumnWidth Link to comment Share on other sites More sharing options...
Verssuss Posted May 30, 2017 Author Share Posted May 30, 2017 well. i try my best and now i have example what make it impossible to do... lets see we have 1000 rows already... and i insert specyfic item on 5 row... if we want get back right parametr we have to change all params form 5 to end of the list lol sorry i just realized that... i still know its possible but it will take to long to change all items into right way tell me im right xD i have to stay in hidden columns but i will ask about it latter PEACE Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now