Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <FileListToArrayNT.au3>
Global $Form1 = GUICreate("Form1", 800, 600, 192, 124)
Global $DCIM, $aItem_ControlID, $dPic
GUICtrlCreateLabel("Ma carte mémoire", 10, 10, 100, 20)
GUICtrlSetFont(-1, 9, 400, 0, "comic sans ms")
$mySD = GUICtrlCreateInput("", 10, 30, 220, 20, $ES_READONLY)
GUICtrlSetFont(-1, 9, 400, 0, "comic sans ms")
$razSD = GUICtrlCreateButton("Actualiser", 320, 30, 80, 20)
$Quit_apnSD = GUICtrlCreateButton("Quitter", 410, 30, 80, 20)
$mySD_LV = GUICtrlCreateListView("Dossier|Date de création", 10, 90, 230, 200, $LVS_SORTDESCENDING, $LVS_EX_GRIDLINES)
GUICtrlSendMsg(-1, 0x101E, 0, 80)
GUICtrlSendMsg(-1, 0x101E, 1, 140)
$ListDir = GUICtrlCreateButton("Lister ce dossier", 140, 300, 100, 20)
$imgSD_LV = GUICtrlCreateListView("Image|Date de création|Largeur|Hauteur", 260, 90, 450, 200, $LVS_SORTDESCENDING, $LVS_EX_GRIDLINES)
GUICtrlSendMsg(-1, 0x101E, 0, 110)
GUICtrlSendMsg(-1, 0x101E, 1, 110)
GUICtrlSendMsg(-1, 0x101E, 2, 110)
GUICtrlSendMsg(-1, 0x101E, 2, 110)
$PreviewImg = GUICtrlCreateButton("Aperçu de l'image", 390, 300, 100, 20)
razLV()
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $razSD
razLV()
Case $ListDir
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($imgSD_LV))
$Indice = _GUICtrlListView_GetSelectedIndices($mySD_LV) ; récupere l'indice de la ligne sélectionné
$SelectedDir = _GUICtrlListView_GetItem($mySD_LV, Int($Indice), 0); Le 0 permet de recuperer dans la colonne 1
$DCIM_IMG = $DCIM & $SelectedDir[3]
$ArrayIMG = _FileListToArrayNT($DCIM_IMG, "*", 1, 1, False, "", 1)
For $i = 1 To $ArrayIMG[0]
_DimPic($DCIM_IMG & "\" & $ArrayIMG[$i])
Local $ImgVer = FileGetTime($DCIM_IMG & "\" & $ArrayIMG[$i], 1, 0)
GUICtrlCreateListViewItem($ArrayIMG[$i] & "|" & $ImgVer[2] & "-" & $ImgVer[1] & "-" & $ImgVer[0] & "|" & $dPic, $imgSD_LV)
Next
_GUICtrlListView_SetColumn($imgSD_LV, 0, "Image (" & $SelectedDir[3] & ")")
Case $PreviewImg
$Indice = _GUICtrlListView_GetSelectedIndices($imgSD_LV) ; récupere l'indice de la ligne sélectionné
$SelectedImg = _GUICtrlListView_GetItem($imgSD_LV, Int($Indice), 0); Le 0 permet de recuperer dans la colonne 1
_PreviewPicture($SelectedImg[3])
EndSwitch
WEnd
Func razLV()
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($mySD_LV))
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($imgSD_LV))
Local $DriveLetter[26] = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
For $i = 0 To 25
If FileExists($DriveLetter[$i] & ":\DCIM\") Then $DCIM = $DriveLetter[$i] & ":\DCIM\"
Next
If FileExists($DCIM) Then
GUICtrlSetData($mySD, $DCIM)
GUICtrlSetState($mySD_LV, $gui_enable)
GUICtrlSetState($imgSD_LV, $gui_enable)
$ArrayDir = _FileListToArrayNT($DCIM, "*", 2, 1, False, "", 1)
For $i = 1 To $ArrayDir[0]
Local $DirVer = FileGetTime($DCIM & $ArrayDir[$i], 1, 0)
GUICtrlCreateListViewItem($ArrayDir[$i] & "|" & $DirVer[2] & "-" & $DirVer[1] & "-" & $DirVer[0] & " / " & $DirVer[3] & ":" & $DirVer[4] & ":" & $DirVer[5], $mySD_LV)
Next
Else
GUICtrlSetState($mySD_LV, $gui_disable)
GUICtrlSetState($imgSD_LV, $gui_disable)
GUICtrlSetData($mySD, "aucune carte mémoire SD insérée !")
EndIf
GUICtrlSetState($ListDir, $gui_disable)
GUICtrlSetState($PreviewImg, $gui_disable)
EndFunc ;==>razLV
Func _PreviewPicture($SelectedPicture)
MsgBox(0, "", $DCIM_IMG & "\" & $SelectedPicture)
;~ Global $PreviewGUI = GUICreate("Aperçu : " & $SelectedPicture, 400, 200, 100, 100)
;~ GUISetState(@SW_SHOW)
;~ While 1
;~ $nMsg = GUIGetMsg()
;~ Switch $nMsg
;~ Case $GUI_EVENT_CLOSE
;~ GUIDelete($PreviewGUI)
;~ ExitLoop
;~ EndSwitch
;~ WEnd
EndFunc ;==>_PreviewPicture
Func _DimPic($pic)
Local $sDir_Name = StringRegExpReplace($pic, "(^.*\\)(.*)", "\1")
Local $sFile_Name = StringRegExpReplace($pic, "^.*\\", "")
Local $sDOS_Dir = FileGetShortName($sDir_Name, 1)
Local $oShellApp = ObjCreate("shell.application")
If IsObj($oShellApp) Then
Local $oDir = $oShellApp.NameSpace($sDOS_Dir)
If IsObj($oDir) Then
Local $oFile = $oDir.Parsename($sFile_Name)
If IsObj($oFile) Then
$dPic = StringReplace($oDir.GetDetailsOf($oFile, 31), " x ", "|")
Else
$iError = 3
EndIf
Else
$iError = 2
EndIf
Else
$iError = 1
EndIf
EndFunc ;==>_DimPic
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $wParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView1 = $mySD_LV
$hWndListView2 = $imgSD_LV
If Not IsHWnd($mySD_LV) Then $hWndListView1 = GUICtrlGetHandle($mySD_LV)
If Not IsHWnd($imgSD_LV) Then $hWndListView2 = GUICtrlGetHandle($imgSD_LV)
$tNMHDR = DllStructCreate($tagNMHDR, $lParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView1
Switch $iCode
Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
GUICtrlSetState($ListDir, $gui_enable)
EndSwitch
Case $hWndListView2
Switch $iCode
Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
GUICtrlSetState($PreviewImg, $gui_enable)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY