marcoauto

GUIListViewEx, Drag&Drop and filter

8 posts in this topic

Ciao,
I'm trying to filter a draggable Listview using checkbox, but when I filter a listview (idListiview) and I drag and drop a record to another listview, the listview that i filtered returns not filtered and the record that i would drag and drop is not the correct one
There are 4 listview, LISTVIEWL1, LISTVIEWL2, LISTVIEWL3 and LISTVIEW. The filter must be work for LISTVIEW (and they work)
Where I wrong?
This is my script (Is not complete, but I rewrite it for the forum)

I know that is not an optimized script...
 
Thanks and sorry for my bad english
 
Marco
 

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <EditConstants.au3>
#include "GUIListViewEx.au3"
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include "_FileListToArrayEx_Marco.au3"
#include <Array.au3>

; *******************************************************************************************************
; **************************** LETTURA FILE CODICI DALLE CARTELLE ***************************************
; *******************************************************************************************************

;~ $listaTotaleCodici = _FileListToArrayEx ("images", "*.png", 4);1+4); 1+4+128)   ;<== original
dim $listaTotaleCodici[11]
$listaTotaleCodici[0] = 10
$listaTotaleCodici[1] = "01A_COD1_Tipo1_CHECK2_01_123456789_02_.png"
$listaTotaleCodici[2] = "01A_COD2_Tipo1_CHECK3_02_321456789_01_.png"
$listaTotaleCodici[3] = "02A_COD1_Tipo1_CHECK2_01_231456798_02_.png"
$listaTotaleCodici[4] = "03A_COD1_Tipo2_CHECK1_01_888456789_01_.png"
$listaTotaleCodici[5] = "04A_COD2_Tipo2_CHECK1_01_111456789_02_.png"
$listaTotaleCodici[6] = "05A_COD1_Tipo1_CHECK2_01_777456789_02_.png"
$listaTotaleCodici[7] = "05A_COD1_Tipo3_CHECK1_01_666456789_01_.png"
$listaTotaleCodici[8] = "06A_COD1_Tipo1_CHECK2_01_555456789_02_.png"
$listaTotaleCodici[9] = "07A_COD1_Tipo3_CHECK2_01_444456789_01_.png"
$listaTotaleCodici[10] = "08A_COD1_Tipo1_CHECK2_01_666777789_02_.png"
;~ $listaTotaleCodici[11] = "08A_COD2_Tipo1_CHECK3_01_222456789_02_.png"



; read some png files
; Ex:
; 01A_COD_Tipo1_CHECK2_N_NUMBER_XY.png
; 02A_COD_Tipo1_CHECK2_N_NUMBER_XY.png
; 03A_COD_Tipo3_CHECK1_N_NUMBER_XY.png
; where NUMBER is differentfor any png files
; COD has max 2 values (COD1 or COD2)
; Tipo has max 3 values

; *******************************************************************************************************
; ********************************* DICHIARAZIONI VARIABILI *********************************************
; *******************************************************************************************************

dim $aArray[8]
dim $filtrare[13] ;array dove vengono memorizzate le parole da filtrare (899, 01, webcom, ecc ecc)
Global $fatto = 0
Global $iLV_L1,$iLV_L2,$iLV_L3,$iLV_Codici
Dim $idItem[800]
Dim $idItemL1[3]
Dim $idItemL2[3]
Dim $idItemL3[3]

Global $idListviewL1, $idListviewL2, $idListviewL3, $idListview

$x = 120
$y = 96
$offsetxpreview = 24+100
$offsetypreview = 129+96
$offsetx = $offsetxpreview + $x + 24
$offsety = 12
Global $offsetxradio = 345

Global $aList1, $tmp_String
Dim $TotaleCodici[800]
Dim $aTempArray[800]
Dim $idButton[6]
Global $offsetxbutton = 20
Global $offsetybutton = 45
Global $idx=0
Global $b = 0
Global $filtrato = 0


; *******************************************************************************************************
; **************************************** PARTENZA GDI *************************************************
; *******************************************************************************************************

_GDIPlus_Startup()
;~ GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")


; *******************************************************************************************************
; *********************************** CREAZIONE GUI PRINCIPALE ******************************************
; *******************************************************************************************************

$g_hGUI = GUICreate("GUI", 1038, 700, 192, 124)
GUISetState()

Global $Graphic = _GDIPlus_GraphicsCreateFromHWND($g_hGUI)

; *******************************************************************************************************
; **************************************** CREAZIONE CHECKBOX  ******************************************
; *******************************************************************************************************

GUIStartGroup()
$RadioCodice1 = GUICtrlCreateCheckbox("CHECK1", $offsetxradio+112, 10, 100, 17)
GUICtrlSetState($RadioCodice1, $GUI_CHECKED)
$RadioCodice2 = GUICtrlCreateCheckbox("CHECK2", $offsetxradio+227, 10, 100, 17)
GUICtrlSetState($RadioCodice2, $GUI_CHECKED)
$RadioCodice3 = GUICtrlCreateCheckbox("CHECK3", $offsetxradio+341, 10, 100, 17)
GUICtrlSetState($RadioCodice3, $GUI_CHECKED)
$Label1 = GUICtrlCreateLabel("LABEL:", $offsetxradio + 24 + 35, 10+2, 50, 17)

$RadioTipo1 = GUICtrlCreateCheckbox("Tipo1", $offsetxradio+112, 45, 100, 17)
GUICtrlSetState($RadioTipo1, $GUI_CHECKED)
$RadioTipo2 = GUICtrlCreateCheckbox("Tipo2", $offsetxradio+227, 45, 100, 17)
GUICtrlSetState($RadioTipo2, $GUI_CHECKED)
$RadioTipo3 = GUICtrlCreateCheckbox("Tipo3", $offsetxradio+341, 45, 100, 17)
GUICtrlSetState($RadioTipo3, $GUI_CHECKED)
$LabelTipo = GUICtrlCreateLabel("TIPO:", $offsetxradio + 24 + 35, 45+2, 50, 17)

Global $offsetxradio = 345
;~ GUIStartGroup()
$Radio1 = GUICtrlCreateCheckbox("A", $offsetxradio+112, 80, 50, 17)
;~  Local $idCheckbox = GUICtrlCreateCheckbox("Standard Checkbox", 10, 10, 185, 25)
GUICtrlSetState($Radio1, $GUI_CHECKED)
$Radio2 = GUICtrlCreateCheckbox("B", $offsetxradio+169, 80, 50, 17)
GUICtrlSetState($Radio2, $GUI_CHECKED)
$Radio3 = GUICtrlCreateCheckbox("C", $offsetxradio+227, 80, 50, 17)
GUICtrlSetState($Radio3, $GUI_CHECKED)
$Radio4 = GUICtrlCreateCheckbox("D", $offsetxradio+284, 80, 50, 17)
GUICtrlSetState($Radio4, $GUI_CHECKED)
$Radio5 = GUICtrlCreateCheckbox("E", $offsetxradio+341, 80, 50, 17)
GUICtrlSetState($Radio5, $GUI_CHECKED)
$Radio6 = GUICtrlCreateCheckbox("F", $offsetxradio+399, 80, 50, 17)
GUICtrlSetState($Radio6, $GUI_CHECKED)
$Radio7 = GUICtrlCreateCheckbox("ALL", $offsetxradio+456, 80, 50, 17)
GUICtrlSetState($Radio7, $GUI_CHECKED)
$LabelGruppi = GUICtrlCreateLabel("LABEL:", $offsetxradio + 24 + 35, 80+2, 50, 17)

$ButtonFiltra = GUICtrlCreateButton("Filter", 870, 12, 150, 84)
;~ GUICtrlSetBkColor(-1,0x00FF00

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($Graphic)
$hPen = _GDIPlus_PenCreate(0xff000000, 2);red, 3pixels wide

; *******************************************************************************************************
; **************************************** CREAZIONE BOTTONI  *******************************************
; *******************************************************************************************************

$cDelete_Button = GUICtrlCreateButton("Delete Line", 870, 115, 150, 30)


$idListviewL1 = GUICtrlCreateListView("LISTVIEWL1", 400, 6+96, 450, 96)
_GUICtrlListView_SetColumnWidth($idListviewL1, 0, 446)
$idListviewL2 = GUICtrlCreateListView("LISTVIEWL2", 400, 6+96+96, 450, 96)
_GUICtrlListView_SetColumnWidth($idListviewL2, 0, 446)
$idListviewL3 = GUICtrlCreateListView("LISTVIEWL3", 400, 6+96+96+96, 450, 96)
_GUICtrlListView_SetColumnWidth($idListviewL3, 0, 446)
$idListview = GUICtrlCreateListView("LISTVIEW", 400, 6+96+96+96+96, 450, 573-96-96-96)
_GUICtrlListView_SetColumnWidth($idListview, 0, 446)

if $fatto = 0 Then
    ConsoleWrite("fatto = 0" & @CRLF)
    For $i = 1 To $listaTotaleCodici[0] ; Loop through the array to display the individual values.
        local $aArray = StringSplit($listaTotaleCodici[$i], '_');, $STR_ENTIRESPLIT) ; Pass the variable to StringSplit and using the delimiter "\n".
        Local $aList[$listaTotaleCodici[0]+1], $sText
        If IsArray($aArray) Then
            $sText =  $aArray[1] & " " & $aArray[2] &  " " & $aArray[3] &  " " & $aArray[4] &  " " & $aArray[6]
            $aList[$i] = $sText
            GUICtrlCreateListViewItem($sText, $idListview)
        EndIf
    Next
    $iLV_Codici = _GUIListViewEx_Init($idListview, $aList, 0, 0, True, 128 + 256)
    $TotaleEtichetteCodici = _GUIListViewEx_ReadToArray($idListview)
    $fatto = 1
EndIf

$iLV_L1 = _GUIListViewEx_Init($idListviewL1, $idItemL1, 0, 0, True) ; No external drop, will drag to others - items deleted on drag
$iLV_L2 = _GUIListViewEx_Init($idListviewL2, $idItemL2, 0, 0, True) ; No external drop, will drag to others - items deleted on drag
$iLV_L3 = _GUIListViewEx_Init($idListviewL3, $idItemL3, 0, 0, True) ; No external drop, will drag to others - items deleted on drag
;~  $iLV_Codici = _GUIListViewEx_Init($idListview, $idItem, 0, 0, True, 128 + 256) ; No external drop, will drag to others - items NOT deleted on drag
;~  GUISetState()
_GUIListViewEx_MsgRegister()

_GUICtrlListView_SetColumnWidth($idListview, 0, $LVSCW_AUTOSIZE_USEHEADER)
_GUICtrlListView_SetColumnWidth($idListview, 1, 1) ; <<<<<<<<<<<<<<<<<<<<<<<<<<

GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

; *******************************************************************************************************
; ********************************************* MAIN LOOP ***********************************************
; *******************************************************************************************************

Global $idMsg
;~     ; Loop until the user exits.
    While 1
        Sleep(10)
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $cDelete_Button
                $listaTotaleCodiciaAttiva = _GUIListViewEx_GetActive()
                ConsoleWrite(" active = " & $listaTotaleCodiciaAttiva & @CRLF)
                if $listaTotaleCodiciaAttiva <> 1 Then
                    _GUIListViewEx_Delete()
                EndIf
            Case $ButtonFiltra
                _filtraCodici()
        EndSwitch
    WEnd

; Clean up resources
_GDIPlus_GraphicsDispose($Graphic)
_GDIPlus_Shutdown()


; *******************************************************************************************************
; ***************************************** QUIT FUNCTION ***********************************************
; *******************************************************************************************************

Func Quit()

    _GDIPlus_Shutdown()
    Exit
EndFunc


; *******************************************************************************************************
; **************************************** ISCHECKED FUNCTION *******************************************
; *******************************************************************************************************

Func _IsChecked($idControlID)
    Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked


; *******************************************************************************************************
; ************************************ WM_NOTIFY FUNCTION ***********************************************
; *******************************************************************************************************

Func WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
    _GUIListViewEx_WM_NOTIFY_Handler($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $index
    $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam)
    $hWndFrom = DllStructGetData($tStruct, 1)
    $idFrom = DllStructGetData($tStruct, 2)
    $code = DllStructGetData($tStruct, 3)
    $index = DllStructGetData($tStruct, 4)
    $hWndListView1 = GUICtrlGetHandle($iLV_L1) ;($idListviewL1)
    $hWndListView2 = GUICtrlGetHandle($iLV_L2) ;($idListviewL2)
    $hWndListView3 = GUICtrlGetHandle($iLV_L3) ;($idListviewL3)
    $hWndListViewCodici = GUICtrlGetHandle($iLV_Codici) ;($idListview)
    Switch $code
        Case $NM_CLICK  ;Left Mouse Button
            ConsoleWrite("left mouse button")
            Switch $idFrom
                Case $iLV_L1
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
;~                     ConsoleWrite("+Click: " & $index & @CRLF)
                    $text = _GUICtrlListView_GetItemText($iLV_L1, DllStructGetData($tInfo, "Index"))
                    ConsoleWrite("+text: " & $text & @CRLF)
            EndSwitch

        Case $NM_DBLCLK ;Double Left Mouse Button
            Switch $idFrom
                Case $idListviewL1
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
;~                     ConsoleWrite("+Click: " & $index & @CRLF)
                    $text = _GUICtrlListView_GetItemText($idListviewL1, DllStructGetData($tInfo, "Index"))
                    ConsoleWrite("+textDBClick: " & $text & @CRLF)
                Case $idListview
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
;~                     ConsoleWrite("+Click: " & $index & @CRLF)
                    $text = _GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"))
                    ConsoleWrite("+textDBClick: " & $text & @CRLF)
            EndSwitch

        Case $GUI_EVENT_CLOSE
            Quit()

    EndSwitch
EndFunc   ;==>WM_NOTIFY


; *******************************************************************************************************
; ***************************************** FILTRA CODICI ***********************************************
; *******************************************************************************************************

Func _filtraCodici()
            $aTempArray = $TotaleEtichetteCodici ;$listaTotaleCodici
            Local $filtrato = 0
            If _IsChecked($Radio1) Then
        $filtrare[1] = 1
    Else
        $filtrare[1] = "A"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = StringLeft($aTempArray[$b][0],3)
            If StringInStr($tmp_String,$filtrare[1]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($Radio2) Then
        $filtrare[2] = 1
    Else
        $filtrare[2] = "B"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = StringLeft($aTempArray[$b][0],3)
            If StringInStr($tmp_String,$filtrare[2]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($Radio3) Then
        $filtrare[3] = 1
    Else
        $filtrare[3] = "C"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = StringLeft($aTempArray[$b][0],3)
            If StringInStr($tmp_String,$filtrare[3]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($Radio4) Then
        $filtrare[4] = 1
    Else
        $filtrare[4] = "D"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = StringLeft($aTempArray[$b][0],3)
            If StringInStr($tmp_String,$filtrare[4]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($Radio5) Then
        $filtrare[5] = 1
    Else
        $filtrare[5] = "E"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = StringLeft($aTempArray[$b][0],3)
            If StringInStr($tmp_String,$filtrare[5]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($Radio6) Then
        $filtrare[6] = 1
    Else
        $filtrare[6] = "F"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = StringLeft($aTempArray[$b][0],3)
            If StringInStr($tmp_String,$filtrare[6]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($RadioTipo1) Then
        $filtrare[7] = 1
    Else
        $filtrare[7] = "Tipo1"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = $aTempArray[$b][0]
            If StringInStr($tmp_String,$filtrare[7]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($RadioTipo2) Then
        $filtrare[8] = 1
    Else
        $filtrare[8] = "Tipo2"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            $tmp_String = $aTempArray[$b][0]
            If StringInStr($tmp_String,$filtrare[8]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($RadioTipo3) Then
        $filtrare[9] = 1
    Else
        $filtrare[9] = "Tipo3"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            $tmp_String = $aTempArray[$b][0]
            If StringInStr($tmp_String,$filtrare[9]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($RadioCodice1) Then
        $filtrare[10] = 1
    Else
        $filtrare[10] = "CHECK1"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = $aTempArray[$b][0]
            If StringInStr($tmp_String,$filtrare[10]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($RadioCodice2) Then
        $filtrare[11] = 1
    Else
        $filtrare[11] = "CHECK2"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = $aTempArray[$b][0]
    ;~      ConsoleWrite(@CRLF & "$tmp_Stringgg= " & $tmp_String & @CRLF)
            If StringInStr($tmp_String,$filtrare[11]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($RadioCodice3) Then
        $filtrare[12] = 1
    Else
        $filtrare[12] = "CHECK3"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = $aTempArray[$b][0]
    ;~      ConsoleWrite(@CRLF & "$tmp_Stringgg= " & $tmp_String & @CRLF)
            If StringInStr($tmp_String,$filtrare[12]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf
    _ArrayDisplay($aTempArray,"fine ciclo")
    _GUICtrlListView_DeleteAllItems($idListview)
;~  $iLV_Codici = _GUIListViewEx_Close($idListview)
    ConsoleWrite("_GUICtrlListView_DeleteAllItems" & @CRLF)
    IF $filtrato = 0 Then
        For $a=0 to UBound($TotaleEtichetteCodici)-1 ; Loop through the array to display the individual values.
            Local $aList1[UBound($TotaleEtichetteCodici)], $sText
            If IsArray($TotaleEtichetteCodici) Then
                $sText =  $TotaleEtichetteCodici[$a][0]
                ConsoleWrite("sText non filtrato = " & $sText & @CRLF)
                $aList1[$a] = $sText
                GUICtrlCreateListViewItem($sText, $idListview)
            EndIf
        Next
    EndIf
    if $filtrato = 1 Then
        For $a=0 to UBound($aTempArray)-1 ; Loop through the array to display the individual values.
            Global $aList1[UBound($aTempArray)], $sText
            If IsArray($aTempArray) Then
                $sText =  $aTempArray[$a][0]
                ConsoleWrite("sText = " & $sText & @CRLF)
                $aList1[$a] = $sText
                GUICtrlCreateListViewItem($sText, $idListview)
            EndIf
        Next
    EndIf
    $iLV_Codici = _GUIListViewEx_Close($idListview)
    $iLV_Codici = _GUIListViewEx_Init($idListview, $aList1, 0, 0, True, 128 + 256); 0, 0, True, 1 + 2 + 8, "0;2")

EndFunc     ;==>_filtraCodici

Share this post


Link to post
Share on other sites



After you drag and drop you'll have to run the _filtraCodici() function to re-sort your items.


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

ciao,

I can't understand how to intercept in my script the drag and drop function.

thanks

marco

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

You cannot in your script, as it is not the script that handles the drag and drop.

You'll need to modify the GUIListViewEx.au3 functions for the drag and drop to run _filtraCodici() after all is said and done.

In the _GUIListViewEx_WM_LBUTTONUP_Handler() function. put _filtraCodici() at the end like so:

; #FUNCTION# =========================================================================================================
; Name...........: _GUIListViewEx_WM_LBUTTONUP_Handler
; Description ...: Windows message handler for WM_NOTIFY
; Syntax.........: _GUIListViewEx_WM_LBUTTONUP_Handler()
; Requirement(s).: v3.3 +
; Return values .: None
; Author ........: Melba23
; Modified ......:
; Remarks .......: If a WM_LBUTTONUP handler already registered, then call this function from within that handler
; Example........: Yes
;=====================================================================================================================
Func _GUIListViewEx_WM_LBUTTONUP_Handler($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg, $wParam, $lParam

    If Not $iGLVEx_Dragging Then
        Return "GUI_RUNDEFMSG"
    EndIf

    ; Get item count
    Local $iMultipleItems = $iGLVEx_Dragging - 1

    ; Reset flag
    $iGLVEx_Dragging = 0

    ; Get window under mouse cursor
    Local $hCurrent_Wnd = _GUIListViewEx_GetCursorWnd()

    ; Abandon if mouse not within tgt ListView
    If $hCurrent_Wnd <> $hGLVEx_TgtHandle Then
        ; Clear insert mark
        _GUICtrlListView_SetInsertMark($hGLVEx_TgtHandle, -1, True)
        ; Reset highlight to original items in Src ListView
        For $i = 0 To $iMultipleItems
            _GUIListViewEx_Highlight($hGLVEx_TgtHandle, $cGLVEx_TgtID, $iGLVEx_DraggedIndex + $i)
        Next
        ; Delete copied arrays
        $aGLVEx_SrcArray = 0
        $aGLVEx_TgtArray = 0
        Return
    EndIf

    ; Clear insert mark
    _GUICtrlListView_SetInsertMark($hGLVEx_TgtHandle, -1, True)

    ; Clear drag image
    If $hGLVEx_DraggedImage Then
        _GUIImageList_DragLeave($hGLVEx_SrcHandle)
        _GUIImageList_EndDrag()
        _GUIImageList_Destroy($hGLVEx_DraggedImage)
        $hGLVEx_DraggedImage = 0
    EndIf

    ; Dropping within same ListView
    If $hGLVEx_SrcHandle = $hGLVEx_TgtHandle Then
        ; Determine position to insert
        If $fGLVEx_BarUnder Then
            If $iGLVEx_DraggedIndex > $iGLVEx_InsertIndex Then $iGLVEx_InsertIndex += 1
        Else
            If $iGLVEx_DraggedIndex < $iGLVEx_InsertIndex Then $iGLVEx_InsertIndex -= 1
        EndIf

        ; Check not dropping on dragged item(s)
        Switch $iGLVEx_InsertIndex
            Case $iGLVEx_DraggedIndex To $iGLVEx_DraggedIndex + $iMultipleItems
                ; Reset highlight to original items
                For $i = 0 To $iMultipleItems
                    _GUIListViewEx_Highlight($hGLVEx_SrcHandle, $cGLVEx_SrcID, $iGLVEx_DraggedIndex + $i)
                Next
                ; Delete copied arrays
                $aGLVEx_SrcArray = 0
                $aGLVEx_TgtArray = 0
                Return
        EndSwitch

        ; Create Local array for checkboxes (if no checkboxes makes no difference)
        Local $aCheck_Array[UBound($aGLVEx_SrcArray)]
        For $i = 1 To UBound($aCheck_Array) - 1
            $aCheck_Array[$i] = _GUICtrlListView_GetItemChecked($hGLVEx_SrcHandle, $i - 1)
        Next

        ; Create Local array for dragged items checkbox state
        Local $aCheckDrag_Array[$iMultipleItems + 1]

        ; Amend arrays
        ; Get data from dragged element(s)
        If $iMultipleItems Then
            ; Multiple dragged elements
            Local $aInsertData[$iMultipleItems + 1]
            For $i = 0 To $iMultipleItems
                Local $aItemData[UBound($aGLVEx_SrcArray, 2)]
                For $j = 0 To UBound($aGLVEx_SrcArray, 2) - 1
                    $aItemData[$j] = $aGLVEx_SrcArray[$iGLVEx_DraggedIndex + 1 + $i][$j]
                Next
                $aInsertData[$i] = $aItemData
                $aCheckDrag_Array[$i] = _GUICtrlListView_GetItemChecked($hGLVEx_SrcHandle, $iGLVEx_DraggedIndex + $i)
            Next
        Else
            ; Single dragged element
            Local $aInsertData[1]
            Local $aItemData[UBound($aGLVEx_SrcArray, 2)]
            For $i = 0 To UBound($aGLVEx_SrcArray, 2) - 1
                $aItemData[$i] = $aGLVEx_SrcArray[$iGLVEx_DraggedIndex + 1][$i]
            Next
            $aInsertData[0] = $aItemData
            $aCheckDrag_Array[0] = _GUICtrlListView_GetItemChecked($hGLVEx_SrcHandle, $iGLVEx_DraggedIndex)
        EndIf

        ; Delete dragged element(s) from arrays
        For $i = 0 To $iMultipleItems
            _GUIListViewEx_Array_Delete($aGLVEx_SrcArray, $iGLVEx_DraggedIndex + 1)
            _GUIListViewEx_Array_Delete($aCheck_Array, $iGLVEx_DraggedIndex + 1)
        Next

        ; Amend insert positon for multiple items deleted above
        If $iGLVEx_DraggedIndex < $iGLVEx_InsertIndex Then
            $iGLVEx_InsertIndex -= $iMultipleItems
        EndIf

        ; Re-insert dragged element(s) into array
        For $i = $iMultipleItems To 0 Step -1
            _GUIListViewEx_Array_Insert($aGLVEx_SrcArray, $iGLVEx_InsertIndex + 1, $aInsertData[$i])
            _GUIListViewEx_Array_Insert($aCheck_Array, $iGLVEx_InsertIndex + 1, $aCheckDrag_Array[$i])
        Next

        ; Rewrite ListView to match array
        _GUIListViewEx_ReWriteLV($hGLVEx_SrcHandle, $aGLVEx_SrcArray, $aCheck_Array, $iGLVEx_SrcIndex)

        ; Set highlight to inserted item(s)
        For $i = 0 To $iMultipleItems
            _GUIListViewEx_Highlight($hGLVEx_SrcHandle, $cGLVEx_SrcID, $iGLVEx_InsertIndex + $i)
        Next

        ; Store amended array
        $aGLVEx_Data[$aGLVEx_Data[0][1]][2] = $aGLVEx_SrcArray
        ; Delete copied arrays
        $aGLVEx_SrcArray = 0
        $aGLVEx_TgtArray = 0

    Else ; Dropping in another ListView

        ; Determine position to insert
        If $fGLVEx_BarUnder Then
            $iGLVEx_InsertIndex += 1
        EndIf

        ; Amend array
        ; Get data from dragged element(s)
        If $iMultipleItems Then
            ; Multiple dragged elements
            Local $aInsertData[$iMultipleItems + 1]
            For $i = 0 To $iMultipleItems
                Local $aItemData[UBound($aGLVEx_SrcArray, 2)]
                For $j = 0 To UBound($aGLVEx_SrcArray, 2) - 1
                    $aItemData[$j] = $aGLVEx_SrcArray[$iGLVEx_DraggedIndex + 1 + $i][$j]
                Next
                $aInsertData[$i] = $aItemData
            Next
        Else
            ; Single dragged element
            Local $aInsertData[1]
            Local $aItemData[UBound($aGLVEx_SrcArray, 2)]
            For $i = 0 To UBound($aGLVEx_SrcArray, 2) - 1
                $aItemData[$i] = $aGLVEx_SrcArray[$iGLVEx_DraggedIndex + 1][$i]
            Next
            $aInsertData[0] = $aItemData
        EndIf

        ; Delete dragged element(s) from source array
        If Not BitAnd($aGLVEx_Data[$iGLVEx_SrcIndex][12], 4) Then
            For $i = 0 To $iMultipleItems
                _GUIListViewEx_Array_Delete($aGLVEx_SrcArray, $iGLVEx_DraggedIndex + 1)
            Next
        EndIf
        ; Check if insert index is valid
        If $iGLVEx_InsertIndex  < 0 Then
            $iGLVEx_InsertIndex = _GUICtrlListView_GetItemCount($hGLVEx_TgtHandle)
        EndIf
        ; Insert dragged element(s) into target array
        For $i = $iMultipleItems To 0 Step -1
            _GUIListViewEx_Array_Insert($aGLVEx_TgtArray, $iGLVEx_InsertIndex + 1, $aInsertData[$i])
            ;$aGLVEx_TgtArray[0][0] += 1
        Next

        ; Rewrite ListViews to match arrays
        _GUIListViewEx_ReWriteLV($hGLVEx_SrcHandle, $aGLVEx_SrcArray, $aGLVEx_SrcArray, $iGLVEx_SrcIndex, False)
        _GUIListViewEx_ReWriteLV($hGLVEx_TgtHandle, $aGLVEx_TgtArray, $aGLVEx_TgtArray, $iGLVEx_TgtIndex, False)
        ; Note no checkbox array needed ListViews with them are not interdraggable, so repass normal array and set final parameter

        ; Set highlight to inserted item(s)
        _GUIListViewEx_SetActive($iGLVEx_TgtIndex)
        For $i = 0 To $iMultipleItems
            _GUIListViewEx_Highlight($hGLVEx_TgtHandle, $cGLVEx_TgtID, $iGLVEx_InsertIndex + $i)
        Next

        ; Store amended arrays
        $aGLVEx_Data[$iGLVEx_SrcIndex][2] = $aGLVEx_SrcArray
        $aGLVEx_Data[$iGLVEx_TgtIndex][2] = $aGLVEx_TgtArray

    EndIf

    ; Delete copied arrays
    $aGLVEx_SrcArray = 0
    $aGLVEx_TgtArray = 0
    _filtraCodici() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HERE

EndFunc   ;==>_GUIListViewEx_WM_LBUTTONUP_Handler

Then, you'll need to include your script #include "myscript.au3" at the top. Or you can put the entire function in your script and comment out it in the library (which will comment it out for everything that uses this UDF).

EDIT: Grammar 

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Ciao,

I've done, but one error occurs again:

If you have time try this:

- Run the program

- Drag the second record from Listview to listviewl1 (01A COD2 Tipo1 CHECK3 321456789)

- uncheck CHECK3 and click the Filter button

- all the records in the "LISTVIEW" with CHECK3 are hidden (and it's ok)

- drag and drop second record (02A COD1 Tipo1 CHECK2 231456798) to LISTVIEWL1 and in the LISTVIEWL1 the result is the wrong record (01A COD2 Tipo1 CHECK3 321456789), the filtered one

Seems that the drag and drop function doesn't use the new filtered listview array.

Marco

Share this post


Link to post
Share on other sites

Yes, it has to do with the way the array internally is reflecting with your filtering.


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

ciao

I found the solution!!

I chenged the line

$iLV_Codici = _GUIListViewEx_Close($idListview)

 with

$iLV_Codici = _GUIListViewEx_Close(1)

in my function _filtraCodici() just before the end

So I close and erase the Listview (that is the number 1) and after I re-init the listview whit the new array

I have also deleted the _filtraCodici() in the GUIListViewEx.au3 because is no longer necessary.

Below the new _filtraCodici()

Thanks again MikahS for all

marco

Func _filtraCodici()
            $aTempArray = $TotaleEtichetteCodici ;$listaTotaleCodici
            Local $filtrato = 0
            If _IsChecked($Radio1) Then
        $filtrare[1] = 1
    Else
        $filtrare[1] = "A"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = StringLeft($aTempArray[$b][0],3)
            If StringInStr($tmp_String,$filtrare[1]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($Radio2) Then
        $filtrare[2] = 1
    Else
        $filtrare[2] = "B"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = StringLeft($aTempArray[$b][0],3)
            If StringInStr($tmp_String,$filtrare[2]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($Radio3) Then
        $filtrare[3] = 1
    Else
        $filtrare[3] = "C"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = StringLeft($aTempArray[$b][0],3)
            If StringInStr($tmp_String,$filtrare[3]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($Radio4) Then
        $filtrare[4] = 1
    Else
        $filtrare[4] = "D"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = StringLeft($aTempArray[$b][0],3)
            If StringInStr($tmp_String,$filtrare[4]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($Radio5) Then
        $filtrare[5] = 1
    Else
        $filtrare[5] = "E"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = StringLeft($aTempArray[$b][0],3)
            If StringInStr($tmp_String,$filtrare[5]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($Radio6) Then
        $filtrare[6] = 1
    Else
        $filtrare[6] = "F"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = StringLeft($aTempArray[$b][0],3)
            If StringInStr($tmp_String,$filtrare[6]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($RadioTipo1) Then
        $filtrare[7] = 1
    Else
        $filtrare[7] = "Tipo1"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = $aTempArray[$b][0]
            If StringInStr($tmp_String,$filtrare[7]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($RadioTipo2) Then
        $filtrare[8] = 1
    Else
        $filtrare[8] = "Tipo2"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            $tmp_String = $aTempArray[$b][0]
            If StringInStr($tmp_String,$filtrare[8]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($RadioTipo3) Then
        $filtrare[9] = 1
    Else
        $filtrare[9] = "Tipo3"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            $tmp_String = $aTempArray[$b][0]
            If StringInStr($tmp_String,$filtrare[9]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($RadioCodice1) Then
        $filtrare[10] = 1
    Else
        $filtrare[10] = "CHECK1"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = $aTempArray[$b][0]
            If StringInStr($tmp_String,$filtrare[10]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($RadioCodice2) Then
        $filtrare[11] = 1
    Else
        $filtrare[11] = "CHECK2"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = $aTempArray[$b][0]
    ;~      ConsoleWrite(@CRLF & "$tmp_Stringgg= " & $tmp_String & @CRLF)
            If StringInStr($tmp_String,$filtrare[11]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf

    If _IsChecked($RadioCodice3) Then
        $filtrare[12] = 1
    Else
        $filtrare[12] = "CHECK3"
        $filtrato = 1
        For $b=UBound($aTempArray) -1 to 0 step -1
            Global $tmp_String = $aTempArray[$b][0]
    ;~      ConsoleWrite(@CRLF & "$tmp_Stringgg= " & $tmp_String & @CRLF)
            If StringInStr($tmp_String,$filtrare[12]) Then
                 _ArrayDelete($aTempArray, $b)
            EndIf
        Next
    EndIf
;~  _ArrayDisplay($aTempArray,"fine ciclo")
    _GUICtrlListView_DeleteAllItems($idListview)
;~  $iLV_Codici = _GUIListViewEx_Close($idListview)
    ConsoleWrite("_GUICtrlListView_DeleteAllItems" & @CRLF)
    IF $filtrato = 0 Then
        For $a=0 to UBound($TotaleEtichetteCodici)-1 ; Loop through the array to display the individual values.
            Local $aList1[UBound($TotaleEtichetteCodici)], $sText
            If IsArray($TotaleEtichetteCodici) Then
                $sText =  $TotaleEtichetteCodici[$a][0]
                ConsoleWrite("sText non filtrato = " & $sText & @CRLF)
                $aList1[$a] = $sText
                GUICtrlCreateListViewItem($sText, $idListview)
            EndIf
        Next
    EndIf
    if $filtrato = 1 Then
        For $a=0 to UBound($aTempArray)-1 ; Loop through the array to display the individual values.
            Global $aList1[UBound($aTempArray)], $sText
            If IsArray($aTempArray) Then
                $sText =  $aTempArray[$a][0]
                ConsoleWrite("sText = " & $sText & @CRLF)
                $aList1[$a] = $sText
                GUICtrlCreateListViewItem($sText, $idListview)
            EndIf
        Next
    EndIf
    $iLV_Codici = _GUIListViewEx_Close(1)       ;<==ADDED THIS LINE Close and erase the LISTVIEW
    $iLV_Codici = _GUIListViewEx_Init($idListview, $aList1, 0, 0, True, 128 + 256); 0, 0, True, 1 + 2 + 8, "0;2")

EndFunc     ;==>_filtraCodici

Share this post


Link to post
Share on other sites

Glad you got it figured out. It's my pleasure.  ^_^


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • Innominate
      By Innominate
      How can I filter out everything in a string except for text between specific tags, specifically between <title>Message title</title> and <body id="msgFeedSummaryBody" selected="false">Summary text</body>
       
      I also want to extract the URL, which is given three times:
           1. Message-Id: <https://www.linktopage.htm@localhost.localdomain>
           2. Content-Base: https://linktopage.htm (no closing tag for this, just a line feed with the next one beginning with “Content-Type: “)
           3. <base href="https://www.linktopage.htm">
       
      Having extracted the Message title, Summary text, and URL, I want to save that in one of various text files, with a prompt for user input giving me a way (such as entering a letter, word, or clicking a radio button; the latter is preferable) to specify which file.
       
      Here is the code I have so far:
       
      #include <MsgBoxConstants.au3> Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase HotKeySet("^h", "_copy") While 1 Sleep(100) WEnd Func _copy() Send("^u") ; opens the message source of the news feed in my e-mail client (Thunderbird) showing all of the desired information Sleep(1000) Send("^a") ; select all of it Sleep(1000) Send("^c") ; copy it to clipboard EndFunc Now how can I filter the clipboard contents (as above), add to it (adding “-----------------------” as a separator, display it to the screen (for confirmation), and append it as plain text to one of several different files?
       
      Thank you!
    • UEZ
      By UEZ
      Since I disovered FreeBasic I decided to create a DLL to implement much faster image processing functionality to AutoIt.
      Following functions are implemented yet:
      _GDIPlus_BitmapApplyFilter_BWJJNDithering _GDIPlus_BitmapApplyFilter_Cartoon1 _GDIPlus_BitmapApplyFilter_ColorAccent _GDIPlus_BitmapApplyFilter_Convolution_AnotherBlur _GDIPlus_BitmapApplyFilter_Convolution_BoxBlur _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection1 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection2 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection3 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection4 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection5 _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection6 _GDIPlus_BitmapApplyFilter_Convolution_Emboss1 _GDIPlus_BitmapApplyFilter_Convolution_Emboss45Degree _GDIPlus_BitmapApplyFilter_Convolution_EmbossTopLeftBottomRight _GDIPlus_BitmapApplyFilter_Convolution_Gaussian3x3 _GDIPlus_BitmapApplyFilter_Convolution_Gaussian5x5_1 _GDIPlus_BitmapApplyFilter_Convolution_Gaussian5x5_2 _GDIPlus_BitmapApplyFilter_Convolution_GaussianBlur _GDIPlus_BitmapApplyFilter_Convolution_IntenseEmboss _GDIPlus_BitmapApplyFilter_Convolution_Kirsch _GDIPlus_BitmapApplyFilter_Convolution_Laplace1 _GDIPlus_BitmapApplyFilter_Convolution_Laplace2 _GDIPlus_BitmapApplyFilter_Convolution_Laplace3 _GDIPlus_BitmapApplyFilter_Convolution_LaplacianOfGaussian _GDIPlus_BitmapApplyFilter_Convolution_ManualMatrix _GDIPlus_BitmapApplyFilter_Convolution_MotionBlur _GDIPlus_BitmapApplyFilter_Convolution_Outline3x3 _GDIPlus_BitmapApplyFilter_Convolution_Prewitt _GDIPlus_BitmapApplyFilter_Convolution_Sharpen1 _GDIPlus_BitmapApplyFilter_Convolution_Sharpen2 _GDIPlus_BitmapApplyFilter_Convolution_Sobel _GDIPlus_BitmapApplyFilter_Convolution_SovelVsPrewitt _GDIPlus_BitmapApplyFilter_Convolution_TriangleBlur _GDIPlus_BitmapApplyFilter_Convolution_Unsharp _GDIPlus_BitmapApplyFilter_Convolution_Unsharp5x5 _GDIPlus_BitmapApplyFilter_Dilatation _GDIPlus_BitmapApplyFilter_DistortionBlur _GDIPlus_BitmapApplyFilter_Edges _GDIPlus_BitmapApplyFilter_Erosion _GDIPlus_BitmapApplyFilter_FishEye _GDIPlus_BitmapApplyFilter_Indexed _GDIPlus_BitmapApplyFilter_Jitter _GDIPlus_BitmapApplyFilter_Kuwahara _GDIPlus_BitmapApplyFilter_Linellism _GDIPlus_BitmapApplyFilter_Median _GDIPlus_BitmapApplyFilter_Median2 _GDIPlus_BitmapApplyFilter_OilPainting _GDIPlus_BitmapApplyFilter_PenSketch _GDIPlus_BitmapApplyFilter_PenSketch2 _GDIPlus_BitmapApplyFilter_Pixelate _GDIPlus_BitmapApplyFilter_Pointillism _GDIPlus_BitmapApplyFilter_RadialBlur _GDIPlus_BitmapApplyFilter_Raster _GDIPlus_BitmapApplyFilter_Swirl _GDIPlus_BitmapApplyFilter_SymmetricNearestNeighbour _GDIPlus_BitmapApplyFilter_TiltShift _GDIPlus_BitmapApplyFilter_TimeWarp _GDIPlus_BitmapApplyFilter_Wave _GDIPlus_BitmapApplyFilter_XRay  
      Since I am absolutely a newbie in FreeBasic, the DLL may contain errors.  Please report any bug.
       
      FreeBasic source code can be found here: https://pastebin.com/Lugp6rCR
       
      To do:
      add function headers with descriptions speed-up FB code -> partly done add more filters -> ongoing  
      Credits to:
      Jakub Szymanowski rdc Dewald Esterhuizen Santhosh G_  Christian Graus www.gutgames.com  
      Have fun.
       
      Download link: 
       
      You can compare the speed with AutoIt version:
      #AutoIt3Wrapper_Version=b #include <Array.au3> #include <GDIPlus.au3> Global $sFile = FileOpenDialog("Select an image", "", "Images (*.jpg;*.png;*.gif;*.bmp)") If @error Then Exit _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172 Global Const $hImage = _GDIPlus_ImageLoadFromFile($sFile) Global Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Global Const $hGUI = GUICreate("GDI+ Image Filters", $iW * 2, $iH) Global $fProg = 0, $iEnd = $iW * $iH - 1 AdlibRegister("Progress", 490) Global $t = TimerInit() Global Const $hGDIBitmap = _GDIPlus_BitmapApplyFilter_Median($hImage, 4) ConsoleWrite(Round(TimerDiff($t) / 1000, 2) & " s / " & Round(TimerDiff($t) / 60000, 2) & " min" & @CRLF) Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW - 1, $iH - 1) Global Const $iPic_o = GUICtrlCreatePic("", $iW, 0, $iW - 1, $iH - 1) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBitmap)) Global Const $hGDIBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic_o, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBitmap2)) GUISetState() AdlibUnRegister("Progress") ToolTip("") Do Until GUIGetMsg() = -3 _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($hGDIBitmap) _WinAPI_DeleteObject($hGDIBitmap2) _GDIPlus_Shutdown() Exit Func Progress() ToolTip(Int($fProg / $iEnd * 100) & " % / " & Round(TimerDiff($t) / 60000, 2) & " min", MouseGetPos(0) + 30, MouseGetPos(1) + 30) EndFunc #Region Symmetric Nearest Neighbour Func _GDIPlus_BitmapApplyFilter_SymmetricNearestNeighbour($hImage, $fRadius = 2, $bGDI = True) ;no alpha channel implemented yet Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Local Const $hBitmap_Dest = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $tBitmapData_Dest = _GDIPlus_BitmapLockBits($hBitmap_Dest, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMWRITE, $GDIP_PXF32ARGB) Local Const $iScan0_Dest = DllStructGetData($tBitmapData_Dest, "Scan0") Local Const $tPixel_Dest = DllStructCreate("int[" & $iW * $iH & "];", $iScan0_Dest) Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local Const $iScan0 = DllStructGetData($tBitmapData, "Scan0") Local Const $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0) Local $iRowOffset, $iX, $iY, $c, $k, $sumR, $sumG, $sumB, $iCount, $xx, $yy, $iR, $iG, $iB, $iR1, $iG1, $iB1, $iR2, $iG2, $iB2, $x, $y For $iY = 0 To $iH - 1 $iRowOffset = $iY * $iW For $iX = 0 To $iW - 1 $sumR = 0 $sumG = 0 $sumB = 0 $iCount = 0 $c = DllStructGetData($tPixel, 1, $iRowOffset + $iX) $iR = BitShift(BitAND(0x00FF0000, $c), 16) $iG = BitShift(BitAND(0x0000FF00, $c), 8) $iB = BitAND(0x000000FF, $c) For $yy = -$fRadius To $fRadius For $xx = -$fRadius To $fRadius $k = $iX + $xx $x = $k < 0 ? 0 : $k > $iW - 1 ? $iW - 1 : $k $k = $iY + $yy $y = $k < 0 ? 0 : $k > $iH - 1 ? $iH - 1 : $k $c = DllStructGetData($tPixel, 1, $y * $iW + $x) $iR1 = BitShift(BitAND(0x00FF0000, $c), 16) $iG1 = BitShift(BitAND(0x0000FF00, $c), 8) $iB1 = BitAND(0x000000FF, $c) $k = $iX - $xx $x = $k < 0 ? 0 : $k > $iW - 1 ? $iW - 1 : $k $k = ($iY - $yy) $y = $k < 0 ? 0 : $k > $iH - 1 ? $iH - 1 : $k $c = DllStructGetData($tPixel, 1, $y * $iW + $x) $iR2 = BitShift(BitAND(0x00FF0000, $c), 16) $iG2 = BitShift(BitAND(0x0000FF00, $c), 8) $iB2 = BitAND(0x000000FF, $c) If __DeltaE($iR, $iG, $iB, $iR1, $iG1, $iB1) < __DeltaE($iR, $iG, $iB, $iR2, $iG2, $iB2) Then $sumR += $iR1 $sumG += $iG1 $sumB += $iB1 Else $sumR += $iR2 $sumG += $iG2 $sumB += $iB2 EndIf $iCount += 1 Next Next DllStructSetData($tPixel_Dest, 1, 0xFF000000 + Int($sumR / $iCount) * 0x10000 + Int($sumG / $iCount) * 0x100 + Int($sumB / $iCount), $iRowOffset + $iX) $fProg += 1 Next Next _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData) _GDIPlus_BitmapUnlockBits($hBitmap_Dest, $tBitmapData_Dest) _GDIPlus_ImageSaveToFile($hBitmap_Dest, @ScriptDir & "\Filter_SNN" & $fRadius & "_" & @YEAR & @MON & @MDAY & @MIN & @SEC & ".png") If $bGDI Then Local $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Dest) _GDIPlus_BitmapDispose($hBitmap_Dest) Return $hGDIBitmap EndIf Return $hBitmap_Dest EndFunc Func __DeltaE($iR1, $iG1, $iB1, $iR2, $iG2, $iB2) Return Sqrt(($iR1 - $iR2) * ($iR1 - $iR2) + ($iG1 - $iG2) * ($iG1 - $iG2) + ($iB1 - $iB2) * ($iB1 - $iB2)) EndFunc #EndRegion #Region Jitter Func _GDIPlus_BitmapApplyFilter_Jitter($hImage, $iAmount = 20, $bGDI = True) Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Local Const $hBitmap_Dest = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $tBitmapData_Dest = _GDIPlus_BitmapLockBits($hBitmap_Dest, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMWRITE, $GDIP_PXF32ARGB) Local Const $iScan0_Dest = DllStructGetData($tBitmapData_Dest, "Scan0") Local Const $tPixel_Dest = DllStructCreate("int[" & $iW * $iH & "];", $iScan0_Dest) Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local Const $iScan0 = DllStructGetData($tBitmapData, "Scan0") Local Const $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0) Local $iX, $iY, $iRowOffset, $fNX, $fNY For $iY = 0 To $iH - 1 $iRowOffset = $iY * $iW + 1 For $iX = 0 To $iW - 1 $fNX = $iX + Int((Random() - 0.5) * $iAmount) $fNX = $fNX < 1 ? 1 : $fNX > $iW - 1 ? $iW - 1 : $fNX $fNY = ($iY + Int((Random() - 0.5) * $iAmount)) $fNY = $fNY < 1 ? 1 : $fNY > $iH - 1 ? $iH - 1 : $fNY $fNY *= $iW DllStructSetData($tPixel_Dest, 1, DllStructGetData($tPixel, 1, $fNY + $fNX), $iRowOffset + $iX) $fProg += 1 Next Next _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData) _GDIPlus_BitmapUnlockBits($hBitmap_Dest, $tBitmapData_Dest) _GDIPlus_ImageSaveToFile($hBitmap_Dest, @ScriptDir & "\Filter_Jitter" & $iAmount & "_" & @YEAR & @MON & @MDAY & @MIN & @SEC & ".png") If $bGDI Then Local $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Dest) _GDIPlus_BitmapDispose($hBitmap_Dest) Return $hGDIBitmap EndIf Return $hBitmap_Dest EndFunc #EndRegion #Region Median Func _GDIPlus_BitmapApplyFilter_Median($hImage, $fRadius = 3, $bGDI = True) Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) Local Const $hBitmap_Dest = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $tBitmapData_Dest = _GDIPlus_BitmapLockBits($hBitmap_Dest, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMWRITE, $GDIP_PXF32ARGB) Local Const $iScan0_Dest = DllStructGetData($tBitmapData_Dest, "Scan0") Local Const $tPixel_Dest = DllStructCreate("int[" & $iW * $iH & "];", $iScan0_Dest) Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW - 1, $iH - 1, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local Const $iScan0 = DllStructGetData($tBitmapData, "Scan0") Local Const $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0) Local $iX, $iY, $iRowOffset For $iY = 0 To $iH - 1 $iRowOffset = $iY * $iW + 1 For $iX = 0 To $iW - 1 DllStructSetData($tPixel_Dest, 1, __Median_Value($iX, $iY, $fRadius, $tPixel, $iW, $iH), $iRowOffset + $iX) $fProg += 1 Next Next _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData) _GDIPlus_BitmapUnlockBits($hBitmap_Dest, $tBitmapData_Dest) _GDIPlus_ImageSaveToFile($hBitmap_Dest, @ScriptDir & "\Filter_Median" & $fRadius & "_" & @YEAR & @MON & @MDAY & @MIN & @SEC & ".png") If $bGDI Then Local $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Dest) _GDIPlus_BitmapDispose($hBitmap_Dest) Return $hGDIBitmap EndIf Return $hBitmap_Dest EndFunc Func __Median_Value($iPosX, $iPosY, $fRadius, $tPixel, $iW, $iH) Local $iX, $iY, $aColors[1000], $iColors = 0, $iSize = $iW * $iH - 1, $iOff, $e For $iX = $iPosX - $fRadius To $iPosX + $fRadius For $iY = $iPosY - $fRadius To $iPosY + $fRadius $iOff = 1 + $iY * $iW + $iX $aColors[$iColors] = DllStructGetData($tPixel, 1, $iOff < 1 ? 1 : $iOff > $iSize ? $iSize : $iOff) $iColors += 1 Next Next ReDim $aColors[$iColors] ;~ _ArraySort($aColors, 0) $e = $iColors - 1 __ArrayQuickSort1D($aColors, 0, $e) Local $iMid = Floor($iColors / 2), $iMedian If BitAND($iColors, 1) Then $iMedian = Int($aColors[$iMid + 1]) Else $iMedian = Int(($aColors[$iMid] + $aColors[$iMid + 1]) / 2) EndIf Return $iMedian EndFunc #EndRegion  
    • Verssuss
      By Verssuss
      hello guys i have some problems. i never do it before but i need:
      1. simply way to save data from ListView to file and load it by button $button_load after i run program again. plz show me function
      2. is this possible to make button copy ? (selected items)
      3. is here way to add checkbox on each item ??

      here is my simple code.
      #AutoIt3Wrapper_UseX64=Y #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" #include <Array.au3> ; Just for display in example #include <GUIConstants.au3> #include <ButtonConstants.au3> #include <SendMessage.au3> #include <GuiEdit.au3> #include <EditConstants.au3> $GUI = GUICreate("Story", 500, 400,200,200) GUISetState() $ListView = GUICtrlCreateListView("Name|ITEM|DMG|SPEED|PRICE", 10, 10, 300, 300, $LVS_SHOWSELALWAYS) $iLV_Index = _GUIListViewEx_Init($ListView, "", 0, 0, True, 1 + 2 + 8) _GUICtrlListView_SetExtendedListViewStyle($ListView, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES) $button_items = GUICtrlCreateButton("ADD ITEM", 350, 5, 90, 25) $button_random = GUICtrlCreateButton("ADD RANDOM", 350, 35, 90, 25) $button_up = GUICtrlCreateButton("UP", 350, 100, 50, 25) $button_down = GUICtrlCreateButton("DOWN", 350, 140, 50, 25) $button_copy = GUICtrlCreateButton("COPY", 350, 180, 50, 25) ; This is even possible tomake it work ?? $button_del_selected = GUICtrlCreateButton("DEL", 350, 220, 50, 25) $button_load = GUICtrlCreateButton("Load", 350, 300, 33, 30) $button_exit = GUICtrlCreateButton("Exit", 350, 330, 33, 30) Global $iCount = 0, $vData, $iEditMode = 0 _GUIListViewEx_MsgRegister() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $button_exit Exit Case $button_load _load() Case $button_random Global $vData[] = ["Name" & $iCount, "Sword", "450", "5", "3000$"] $iCount += 1 _GUIListViewEx_Insert($vData) Global $vData[] = ["Name" & $iCount, "Axe", "700", "2", "4500$"] $iCount += 1 _GUIListViewEx_Insert($vData) Global $vData[] = ["Name" & $iCount, "Bow", "300", "7", "2000$"] $iCount += 1 _GUIListViewEx_Insert($vData) Global $vData[] = ["Name" & $iCount, "Magic", "1000", "1", "6000$"] $iCount += 1 _GUIListViewEx_Insert($vData) Case $button_items gui2() GUICtrlSetState($GUI, $GUI_DISABLE) Case $button_del_selected _GUIListViewEx_Delete() Case $button_up _GUIListViewEx_SetActive($iLV_Index) _GUIListViewEx_Up() Case $button_down _GUIListViewEx_SetActive($iLV_Index) _GUIListViewEx_Down() EndSwitch $vRet = _GUIListViewEx_EventMonitor($iEditMode) WEnd Func gui2() $pos_GUI2 = WinGetPos($GUI) Local $GUI2 = GUICreate("Items", 300, 300, $pos_GUI2[0]+200, $pos_GUI2[1]+100,-1, $WS_EX_TOPMOST) Local $i1 = GUICtrlCreateInput("", 50, 30, 200, 25) Local $i2 = GUICtrlCreateInput("", 50, 60, 200, 25) Local $i3 = GUICtrlCreateInput("", 50, 90, 200, 25) Local $i4 = GUICtrlCreateInput("", 50, 120, 200, 25) Local $GUI2_button2 = GUICtrlCreateButton("ANULUJ", 80, 200, 50, 30) Local $GUI2_button1 = GUICtrlCreateButton("OK", 170, 200, 50, 30) Local $GUI2_label = GUICtrlCreateLabel("Write stats", 10, 5) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $GUI2_button2 GUIDelete($GUI2) GUICtrlSetState($GUI, $GUI_ENABLE) ExitLoop Case $GUI2_button1 Global $vData[] = ["Name" & $iCount, GUICtrlRead($i1), GUICtrlRead($i2), GUICtrlRead($i3), GUICtrlRead($i4)] $iCount += 1 _GUIListViewEx_Insert($vData) GUIDelete($GUI2) ExitLoop GUICtrlSetState($GUI, $GUI_ENABLE) EndSwitch WEnd EndFunc ;==>gui2 Func _quit() Exit EndFunc ;==>_quit Func _load() EndFunc ;==>_quit thanks u
       
    • david1337
      By david1337
      Hey guys
      I hope that I can get a little help with this one
       
      In this GUI example using GUIListViewEx, I have a list based on items found in test.txt.
      _____________________________________________
      item1
      item2
      item3
      ____________________________________________
      etc....
       
      When an item is selected, and I click the GetInfo button, a message will show the text of that item.
      Is it possible to activate a case like that as soon as the item is selected, so I don't need a button to start the case?
       
      #include <GUIConstantsEx.au3> #include <GUIListViewEx.au3> Global $MainGUI_ManageItemList Global $File = "test.txt" Global $FileToArray = FileReadToArray("test.txt") Call ("MainGUI_ManageItemList") Func MainGUI_ManageItemList() Local $Button1 $MainGUI_ManageItemList = GUICreate("Manage Item List", 800, 400, -1, -1) $cLV = GUICtrlCreateListView("[items]", 10, 10, 400, 775, $LVS_NOCOLUMNHEADER) GUICtrlSetFont(-1, 12, 800, 0, "@Arial Unicode MS") _GUICtrlListView_SetColumnWidth($cLV, 0, 378) $Button1 = GUICtrlCreateButton("Button 1", 425, 10, 80, 30) $RemoveItem = GUICtrlCreateButton("Remove Item", 425, 50, 80, 30) $GetInfo = GUICtrlCreateButton("GetInfo", 425, 120, 80, 30) GUISetState(@SW_SHOW, $MainGUI_ManageItemList) ; Intialise ListView Global $iLV_Index = _GUIListViewEx_Init($cLV) ; Insert lines _GUIListViewEx_Insert($FileToArray, True) ; Register required messages _GUIListViewEx_MsgRegister(True, False, False, False) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Button1 MsgBox(0,"","Button 1 is pressed") Case $RemoveItem _GUIListViewEx_Delete() Case $GetInfo $ItemSelected = _GUICtrlListView_GetSelectedIndices($cLV, True) If IsArray($ItemSelected) And $ItemSelected[0] <> 0 Then ;This part makes sure it doesn't crash when no item is selected. $ItemSelectedText = _GUICtrlListView_GetItemText($cLV, $ItemSelected[1]) msgbox (0, "Selected item", $ItemSelectedText) EndIf EndSwitch WEnd EndFunc ;==>Main  
    • UEZ
      By UEZ
      A collection of image filter effects usable with AutoIt!
       
      IMPORTANT: You are not allowed to sell this code or just parts of it in a commercial project or modify it and distribute it with a different name!
      Distributing copies of this UDF incl. _GDIPlus_BitmapApplyFilter.dll in compiled format (exe) must be free of any fee!
       
      More information can be found in the forum thread!