Jump to content

list view image list help


rootx
 Share

Recommended Posts

Hello guys, I would like to upload images in listview from a folder, but  it does not work well, the list view repeat random the jpg!!

But if I use _GUICtrlListView_SetImageList($idListview, $hImage, 1) the array work fine because write all images paths, the problem come when I try to see the images,  where did i do wrong?

THX

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>

    Global $idListview, $hImage

    GUICreate("ImageList AddBitmap", 800, 600)
    $idListview = GUICtrlCreateListView("", 2, 2, 800, 600, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(64, 64)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Image", 64)

    Local $aArray = _FileListToArrayRec("C:\Users\francesco\Desktop\Nuova cartella", "*.jpg", $FLTAR_FILES, 1, $FLTAR_SORT,$FLTAR_FULLPATH)
    $fileArray = UBound($aArray) -1

    _GDIPlus_Startup()
    For $y = 1 To $fileArray
        $GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory(Binary(FileRead($aArray[$y]))) ;GDI+ image!
        $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, 64,64) ;GDI+ image
        $GDIbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIpBmpResized) ;GDI image!
        $img = _GUIImageList_Add($hImage, $GDIbmp)
        _GUICtrlListView_SetImageList($idListview, $hImage, 1)
         ;Add items
        _GUICtrlListView_AddItem($idListview, $aArray[$y], $img)

    Next

    Do

    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup resources
    _GDIPlus_BitmapDispose($GDIpBmpLarge)
    _GDIPlus_BitmapDispose($GDIpBmpResized)
    _WinAPI_DeleteObject($GDIbmp)
    _GDIPlus_Shutdown()
    GUIDelete()

 

Edited by rootx
Link to comment
Share on other sites

This works for me. I've just been a little bit more accurate with regard to definitions of listview and image list.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>

    Global $idListview, $hImage

    GUICreate("ImageList AddBitmap", 800, 600)
    $idListview = GUICtrlCreateListView("", 2, 2, 800, 600, BitOR($LVS_SHOWSELALWAYS, $LVS_ICON)) ; <<<<<<<<
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $LVS_EX_DOUBLEBUFFER) ; <<<<<<<<
    _GUICtrlListView_SetView( $idListview, 1 ) ; 1 = Large icon <<<<<<<<
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(64, 64, 5, 3) ; <<<<<<<<
    _GUICtrlListView_SetImageList($idListview, $hImage ) ; <<<<<<<<

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Image", 64)

    Local $aArray = _FileListToArrayRec("C:\WINDOWS\Temp\AutoIt", "*.jpg", $FLTAR_FILES, 1, $FLTAR_SORT,$FLTAR_FULLPATH)
    $fileArray = UBound($aArray) -1

    _GDIPlus_Startup()
    For $y = 1 To $fileArray
        Global $GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory(Binary(FileRead($aArray[$y]))) ;GDI+ image!
        Global $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, 64,64) ;GDI+ image
        Global $GDIbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIpBmpResized) ;GDI image!
        $img = _GUIImageList_Add($hImage, $GDIbmp)
        ;_GUICtrlListView_SetImageList($idListview, $hImage, 1) ; <<<<<<<<
         ;Add items
        _GUICtrlListView_AddItem($idListview, $aArray[$y], $img)
    _GDIPlus_BitmapDispose($GDIpBmpLarge) ; <<<<<<<<
    _GDIPlus_BitmapDispose($GDIpBmpResized) ; <<<<<<<<
    _WinAPI_DeleteObject($GDIbmp) ; <<<<<<<<

    Next

    Do

    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup resources
    _GDIPlus_BitmapDispose($GDIpBmpLarge)
    _GDIPlus_BitmapDispose($GDIpBmpResized)
    _WinAPI_DeleteObject($GDIbmp)
    _GDIPlus_Shutdown()
    GUIDelete()

If this is not what you want, then please be more precise about the issues.

Link to comment
Share on other sites

This works for me. I've just been a little bit more accurate with regard to definitions of listview and image list.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>

    Global $idListview, $hImage

    GUICreate("ImageList AddBitmap", 800, 600)
    $idListview = GUICtrlCreateListView("", 2, 2, 800, 600, BitOR($LVS_SHOWSELALWAYS, $LVS_ICON)) ; <<<<<<<<
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $LVS_EX_DOUBLEBUFFER) ; <<<<<<<<
    _GUICtrlListView_SetView( $idListview, 1 ) ; 1 = Large icon <<<<<<<<
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(64, 64, 5, 3) ; <<<<<<<<
    _GUICtrlListView_SetImageList($idListview, $hImage ) ; <<<<<<<<

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Image", 64)

    Local $aArray = _FileListToArrayRec("C:\WINDOWS\Temp\AutoIt", "*.jpg", $FLTAR_FILES, 1, $FLTAR_SORT,$FLTAR_FULLPATH)
    $fileArray = UBound($aArray) -1

    _GDIPlus_Startup()
    For $y = 1 To $fileArray
        Global $GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory(Binary(FileRead($aArray[$y]))) ;GDI+ image!
        Global $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, 64,64) ;GDI+ image
        Global $GDIbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIpBmpResized) ;GDI image!
        $img = _GUIImageList_Add($hImage, $GDIbmp)
        ;_GUICtrlListView_SetImageList($idListview, $hImage, 1) ; <<<<<<<<
         ;Add items
        _GUICtrlListView_AddItem($idListview, $aArray[$y], $img)
    _GDIPlus_BitmapDispose($GDIpBmpLarge) ; <<<<<<<<
    _GDIPlus_BitmapDispose($GDIpBmpResized) ; <<<<<<<<
    _WinAPI_DeleteObject($GDIbmp) ; <<<<<<<<

    Next

    Do

    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup resources
    _GDIPlus_BitmapDispose($GDIpBmpLarge)
    _GDIPlus_BitmapDispose($GDIpBmpResized)
    _WinAPI_DeleteObject($GDIbmp)
    _GDIPlus_Shutdown()
    GUIDelete()

If this is not what you want, then please be more precise about the issues.

Thank LarsJ, but with your fix I do not see the images jpeg on the listview, I see only the path. I would like to see the images scaled.

Link to comment
Share on other sites

I have renamed a few of my images to "jpeg". Then I have changed "jpg" to "jpeg" in the script. It works for me. I see 64x64 pixel images in the listview.

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>

    Global $idListview, $hImage, $g_bSortSense = True, $ini=@ScriptDir&"img.ini"
    Local $aArray = _FileListToArrayRec("C:\Users\francesco\Desktop\imgtest", "*.png", $FLTAR_FILES, 1, $FLTAR_SORT,$FLTAR_FULLPATH)
    $fileArray = UBound($aArray) -1

    GUICreate("Image Album List", 800, 600)
    $idListview = GUICtrlCreateListView("", 2, 2, 800, 600, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
     GUISetState()
    ; Load images
    $hImage = _GUIImageList_Create(64, 64,5,3)
    _GUICtrlListView_SetImageList($idListview, $hImage )

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Image", 64)
    _GUICtrlListView_AddColumn($idListview, "Path", 128)
    _GUICtrlListView_AddColumn($idListview, "Caption", 500)
    ;_GUICtrlListView_HideColumn($idListview, 1)
    _GDIPlus_Startup()
    Local $GDIpBmpLarge,$GDIpBmpResized,$GDIbmp
    For $y = 1 To $fileArray
            ;$ini = IniWrite("img.ini",$aArray[$y],"caption",$aArray[$y]) ;<<< run only the first time, then put a comment
             $GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory(Binary(FileRead($aArray[$y]))) ;GDI+ image!
             $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, 64,64) ;GDI+ image
             $GDIbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIpBmpResized) ;GDI image!
            $img = _GUIImageList_Add($hImage, $GDIbmp)
            _GUICtrlListView_SetImageList($idListview, $hImage, 1)
             ;Add items
            _GUICtrlListView_AddItem($idListview, StringRegExp($aArray[$y], ".*\\(.+)$", 1), $img) ;image
            _GUICtrlListView_AddSubItem($idListview, $y-1,$aArray[$y],1)
            _GUICtrlListView_AddSubItem($idListview, $y,IniRead("img.ini",$aArray[$y],"caption",""),2) ;caption
            ConsoleWrite($img&" "&$aArray[$y]&@LF)
    Next

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ;cleanup resources
    _GDIPlus_BitmapDispose($GDIpBmpLarge)
    _GDIPlus_BitmapDispose($GDIpBmpResized)
    _WinAPI_DeleteObject($GDIbmp)
    _GDIPlus_Shutdown()
    GUIDelete()

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $hWndListView = $idListview
    If Not IsHWnd($idListview) Then $hWndListView = GUICtrlGetHandle($idListview)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    $path = IniRead("cfg.ini","PAGE","sourcedir","")
                     Local $iItemText = _GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"),2)
                     Local $iLen = _GUICtrlListView_GetStringWidth($idListview, $iItemText)
                     Local $sValue = InputBox("Edit Image", "Enter your description.", ""," M100")
                     $iIndex = _GUICtrlListView_GetSelectedIndices($idListview)
                     _GUICtrlListView_SetItemText($idListview,$iIndex,$sValue,2)
                      If $sValue <> "" Then
                         IniWrite("img.ini",_GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"),1),"caption",$sValue)
                      Else
                          _GUICtrlListView_SetItemText($idListview,$iIndex,$iItemText,3)
                      EndIf

                    Case $LVN_COLUMNCLICK ; A column was clicked
                    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    ; Kick off the sort callback
                    _GUICtrlListView_SortItems($idListview, _GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"),1))

                    Case $LVN_COLUMNCLICK ; A column was clicked

                    _GUICtrlListView_SimpleSort($idListview, $g_bSortSense, 1, true)

                    Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    MsgBox($MB_ICONINFORMATION,"IMAGE PATH",_GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"),1))

                    Return 0 ; allow the default processing
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

 

Ok, I upload all...

I want to take pictures from a folder, enter them in the listview, right mouse button to see the path, double click left button writes a description in an ini file, when I will restart the script I want to see the description entered before.

Edited by rootx
Link to comment
Share on other sites

Try this. I have not coded everything but focused on the listview.

#include <GUIConstants.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <GDIPlus.au3>
#include <File.au3>

Opt( "MustDeclareVars", 1 )

#cs ; Needed on AutoIt 3.3.10
Global Const $FLTAR_FILESFOLDERS = 0
Global Const $FLTAR_FILES = 1
Global Const $FLTAR_FOLDERS = 2
Global Const $FLTAR_NOHIDDEN = 4
Global Const $FLTAR_NOSYSTEM = 8
Global Const $FLTAR_NOLINK = 16
Global Const $FLTAR_NORECUR = 0
Global Const $FLTAR_RECUR = 1
Global Const $FLTAR_NOSORT = 0
Global Const $FLTAR_SORT = 1
Global Const $FLTAR_FASTSORT = 2
Global Const $FLTAR_NOPATH = 0
Global Const $FLTAR_RELPATH = 1
Global Const $FLTAR_FULLPATH = 2
#ce

Global $hListView, $idOnLvRightClick, $idOnLvDoubleClick

Example()


Func Example()
  GUICreate( "Image Album List", 800, 650 )

  Local $idListView = GUICtrlCreateListView("", 2, 2, 796, 646, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
  _GUICtrlListView_SetExtendedListViewStyle($idListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
  _GUICtrlListView_AddColumn($idListView, "Image", 140) ; Must not be too small
  _GUICtrlListView_AddColumn($idListView, "Path",  128)
  _GUICtrlListView_AddColumn($idListView, "Caption", 450)
  $hListView = GUICtrlGetHandle( $idListView )

  Local $hImage = _GUIImageList_Create(128, 128, 5, 3)
  _GUICtrlListView_SetImageList($hListView, $hImage, 1)

  $idOnLvDoubleClick = GUICtrlCreateDummy()
  $idOnLvRightClick = GUICtrlCreateDummy()

  _GDIPlus_Startup()
  Local $aArray = _FileListToArrayRec(".", "*.jpg;*.jpeg", $FLTAR_FILES, 1, $FLTAR_SORT,$FLTAR_FULLPATH)
  Local $iArray = UBound($aArray) - 1, $GDIpBmpLarge,$GDIpBmpResized,$GDIbmp,$img
  For $i = 1 To $iArray - 1
    $GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory(Binary(FileRead($aArray[$i]))) ;GDI+ image!
    $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, 128,128) ;GDI+ image
    $GDIbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIpBmpResized) ;GDI image!
    $img = _GUIImageList_Add($hImage, $GDIbmp )
    _GUICtrlListView_AddItem($idListview, "", $img)
    _GUICtrlListView_AddSubItem($idListview, $i-1,$aArray[$i],1)
    _GUICtrlListView_AddSubItem($idListview, $i-1,IniRead("img.ini",$aArray[$i],"caption",""),2)
    _GDIPlus_BitmapDispose($GDIpBmpLarge)
    _GDIPlus_BitmapDispose($GDIpBmpResized)
    _WinAPI_DeleteObject($GDIbmp)
  Next
  _GDIPlus_Shutdown()

  GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

  GUISetState( @SW_SHOW )

  ; Message loop
  While 1
    Switch GUIGetMsg()
      Case $idOnLvDoubleClick
        Local $iIndex = GUICtrlRead( $idOnLvDoubleClick )
        Local $sValue = InputBox("Edit Image", "Enter your description.", ""," M100")
      Case $idOnLvRightClick
        Local $iIndex = GUICtrlRead( $idOnLvRightClick )
        MsgBox(0,"IMAGE PATH",_GUICtrlListView_GetItemText($idListview, $iIndex,1))
      Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
  WEnd

  ; Cleanup
  GUIDelete()
EndFunc

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
  #forceref $hWnd, $iMsg, $wParam
  Local $hWndFrom, $iCode, $tNMHDR, $tInfo

  $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
  $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
  $iCode = DllStructGetData($tNMHDR, "Code")
  Switch $hWndFrom
    Case $hListView
      Switch $iCode
        Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
          $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
          GUICtrlSendToDummy( $idOnLvDoubleClick, DllStructGetData($tInfo, "Index") )

        Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
          $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
          GUICtrlSendToDummy( $idOnLvRightClick, DllStructGetData($tInfo, "Index") )
      EndSwitch
  EndSwitch
  Return $GUI_RUNDEFMSG
EndFunc

Images.7z

Edited by LarsJ
Link to comment
Share on other sites

Use

$GDIpBmpLarge = _GDIPlus_ImageLoadFromFile($aArray[$i]) ;GDI+ image!

and it should work.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

UEZ, What's the difference when using your command? I must admit that I can not see any difference. To me, all the images looks fine with both commands including the images in imgtest.7z (apart from proportions because rectangular images are scaled into square images).

Link to comment
Share on other sites

On my PC I get the same issue as rootx. The problem seems to be how the file are opened - not the GDIPlus functions.

This will also work properly:

$h = FileOpen($aArray[$i], 16)
    $b = FileRead($h)
    FileClose($h)
    $GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory($b) ;GDI+ image!

I don't know why two files are failing when they are loaded via

$GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory(Binary(FileRead($aArray[$i])))

Maybe an internal conversation during the load is made for both images.

 

Btw, _GDIPlus_BitmapCreateFromMemory() is not made to load images from disk, rather from memory!

 

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>

    Global $idListview, $hImage, $ini=@ScriptDir&"img.ini"

    GUICreate("Image Album List", 800, 700)
    $idListview = GUICtrlCreateListView("", 2, 2, 800, 600, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
     GUISetState()
    ; Load images
    $hImage = _GUIImageList_Create(64, 64,5,3)
    _GUICtrlListView_SetImageList($idListview, $hImage )

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Image", 64)
    _GUICtrlListView_AddColumn($idListview, "Path", 350)
    _GUICtrlListView_AddColumn($idListview, "Caption",382)
    ;_GUICtrlListView_HideColumn($idListview, 1)
    _GDIPlus_Startup()
    Local $GDIpBmpLarge,$GDIpBmpResized,$GDIbmp

    Local $aArray = _FileListToArrayRec("C:\Users\francesco\Desktop\1", "*.png", $FLTAR_FILES, 1, $FLTAR_SORT,$FLTAR_FULLPATH)
    $fileArray = UBound($aArray) -1
    For $y = 1 To $fileArray
        ;$ini = IniWrite("img.ini",$aArray[$y],"caption",$aArray[$y]) ;<<< run only the first time, then put a comment
        $GDIpBmpLarge = _GDIPlus_ImageLoadFromFile($aArray[$y]) ;GDI+ image!
        $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, 64,64) ;GDI+ image
        $GDIbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIpBmpResized) ;GDI image!
        $img = _GUIImageList_Add($hImage, $GDIbmp)
        _GUICtrlListView_SetImageList($idListview, $hImage, 1)
        ;Add items
        _GUICtrlListView_AddItem($idListview, StringRegExp($aArray[$y], ".*\\(.+)$", 1), $img) ;image
        _GUICtrlListView_AddSubItem($idListview, $y-1,$aArray[$y],1)
        _GUICtrlListView_AddSubItem($idListview, $y-1,IniRead("img.ini",$aArray[$y],"caption",""),2) ;caption
        ConsoleWrite($img&" "&$aArray[$y]&@LF)
    Next

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ;cleanup resources
    _GDIPlus_BitmapDispose($GDIpBmpLarge)
    _GDIPlus_BitmapDispose($GDIpBmpResized)
    _WinAPI_DeleteObject($GDIbmp)
    _GDIPlus_Shutdown()
    GUIDelete()

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $hWndListView = $idListview
    If Not IsHWnd($idListview) Then $hWndListView = GUICtrlGetHandle($idListview)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    $path = IniRead("cfg.ini","PAGE","sourcedir","")
                     Local $iItemText = _GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"),2)
                     ;Local $iLen = _GUICtrlListView_GetStringWidth($idListview, $iItemText)
                     Local $sValue = InputBox("Edit Image", "Enter your description.", ""," M100",400,150)
                     Local $iIndex = _GUICtrlListView_GetSelectedIndices($idListview)
                     _GUICtrlListView_SetItemText($idListview,$iIndex,$sValue,2)
                      If $sValue <> "" Then
                         IniWrite("img.ini",_GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"),1),"caption",$sValue)
                      Else
                          _GUICtrlListView_SetItemText($idListview,$iIndex,$iItemText,3)
                      EndIf

                Case $LVN_COLUMNCLICK ; A column was clicked
                    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    ; Kick off the sort callback
                    _GUICtrlListView_SortItems($idListview, _GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"),1))

                Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    MsgBox($MB_ICONINFORMATION,"IMAGE PATH",_GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index"),1))

                    Return 0 ; allow the default processing
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Why is writing a blank line at the end of the for loop? I would like to avoid it, can someone explain to me?

THX

Cattura.JPG

Link to comment
Share on other sites

This line shouldn't be clickable. It it caused by the GUICtrlCreateListView()

For example if you use 16x16 images you will see a lot of more lines because it is created automatically.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I still have not been able to verify the problem with the previous image being displayed several times in place of new images. Windows 7 32/64. AutoIt 3.3.10.

The ghost row in bottom of listview:
You can work around the problem by carefully adjusting the height of the listview to match a whole number of rows.

Link to comment
Share on other sites

  • 3 weeks later...

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
 Share

×
×
  • Create New...