;~ AutoIt Version: 3.3.14.5
#include <GUIConstants.au3>
#include <GUIListView.au3>
#include <GUIImageList.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISysWin.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <ListViewConstants.au3>
Local $tab, $iCombo, $msg, $Gui
$iCombo = GUICtrlCreateCombo("", 20, 70, 310, 120)
Global Const $INI_FILE = StringLeft(@ScriptName, StringInStr(@ScriptName, ".") - 1) & ".ini"
GUICreate("Пример", 400, 600, -1, -1, -1, $WS_EX_ACCEPTFILES)
GUICtrlCreateLabel("Drag && Drop / Двойной ЛКМ > Запустить / ПКМ > Удалить", 0, 0, 400, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetBkColor(0xB4E1D3)
GUISetFont(9, 300)
$tab = GUICtrlCreateTab(10, 22, 380, 570)
GUICtrlCreateTabItem("Путь")
GUICtrlSetImage(-1, "shell32.dll", -222, 0) ; иконка вкладки
Global $g_idLV = GUICtrlCreateListView("Файл", 10, 40, 360, 550, BitOR($LVS_DEFAULT, $LVS_NOSORTHEADER), $WS_EX_CLIENTEDGE)
_GUICtrlListView_SetExtendedListViewStyle($g_idLV, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_INFOTIP, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
_GUICtrlListView_SetColumnWidth($g_idLV, 0, $LVSCW_AUTOSIZE_USEHEADER)
Global $g_hImages = _GUIImageList_Create()
_GUICtrlListView_SetImageList($g_idLV, $g_hImages, 1)
_LoadFiles1()
GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState()
GUICtrlCreateTabItem("Выбор стиля")
GUICtrlSetImage(-1, "shell32.dll", -222, 0) ; иконка вкладки
Global $g_idLV = GUICtrlCreateListView("Файл", 10, 40, 360, 550, BitOR($LVS_DEFAULT, $LVS_NOSORTHEADER), $WS_EX_CLIENTEDGE)
_GUICtrlListView_SetExtendedListViewStyle($g_idLV, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_INFOTIP, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
_GUICtrlListView_SetColumnWidth($g_idLV, 0, $LVSCW_AUTOSIZE_USEHEADER)
Global $g_hImages = _GUIImageList_Create()
_GUICtrlListView_SetImageList($g_idLV, $g_hImages, 1)
_LoadFiles2()
GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState()
GUICtrlCreateTabItem("?")
GUICtrlSetImage(-1, "shell32.dll", -222, 0) ; иконка вкладки
Global $g_idLV = GUICtrlCreateListView("Файл", 10, 40, 360, 550, BitOR($LVS_DEFAULT, $LVS_NOSORTHEADER), $WS_EX_CLIENTEDGE)
_GUICtrlListView_SetExtendedListViewStyle($g_idLV, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_INFOTIP, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
_GUICtrlListView_SetColumnWidth($g_idLV, 0, $LVSCW_AUTOSIZE_USEHEADER)
Global $g_hImages = _GUIImageList_Create()
_GUICtrlListView_SetImageList($g_idLV, $g_hImages, 1)
_LoadFiles3()
GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState()
GUICtrlCreateTabItem("") ; определяет конец вкладок
GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam)
Local $aFiles = _WinAPI_DragQueryFileEx($wParam)
If Not @error Then
For $i = 1 To $aFiles[0]
_AddFile($aFiles[$i])
Next
_WinAPI_DragFinish($wParam)
EndIf
EndFunc ;==>WM_DROPFILES
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $iIndex
$tNMHDR = DllStructCreate($tagNMHDR, $lParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $iIDFrom
Case $g_idLV
Switch $iCode
Case $NM_DBLCLK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
$iIndex = DllStructGetData($tInfo, "Index")
If $iIndex <> -1 Then ShellExecute(_GUICtrlListView_GetItemText($hWndFrom, $iIndex))
Case $NM_RCLICK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
$iIndex = DllStructGetData($tInfo, "Index")
If $iIndex <> -1 Then _GUICtrlListView_DeleteItem($hWndFrom, $iIndex)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _AddFile($sFile)
Local $hIcon = _WinAPI_ShellExtractAssociatedIcon($sFile, 1)
_GUICtrlListView_AddItem($g_idLV, $sFile, _GUIImageList_ReplaceIcon($g_hImages, -1, $hIcon))
_WinAPI_DestroyIcon($hIcon)
EndFunc ;==>_AddFile
Func _LoadFiles1()
Local $iCount = Int(IniRead($INI_FILE, "Files", "Count", "0"))
For $i = 0 To $iCount - 1
_AddFile(IniRead($INI_FILE, "Files", $i, ""))
Next
OnAutoItExitRegister("_SaveFiles1")
EndFunc ;==>_LoadFiles
Func _LoadFiles2()
Local $iCount = Int(IniRead($INI_FILE, "Files", "Count", "0"))
For $i = 0 To $iCount - 1
_AddFile(IniRead($INI_FILE, "Files", $i, ""))
Next
OnAutoItExitRegister("_SaveFiles2")
EndFunc ;==>_LoadFiles
Func _LoadFiles3()
Local $iCount = Int(IniRead($INI_FILE, "Files", "Count", "0"))
For $i = 0 To $iCount - 1
_AddFile(IniRead($INI_FILE, "Files", $i, ""))
Next
OnAutoItExitRegister("_SaveFiles3")
EndFunc ;==>_LoadFiles
Func _SaveFiles1()
Local $iCount = _GUICtrlListView_GetItemCount($g_idLV)
IniWrite($INI_FILE, "Files", "Count", $iCount)
For $i = 0 To $iCount - 1
IniWrite($INI_FILE, "Files", $i, _GUICtrlListView_GetItemText($g_idLV, $i))
Next
EndFunc ;==>_SaveFiles
Func _SaveFiles2()
Local $iCount = _GUICtrlListView_GetItemCount($g_idLV)
IniWrite($INI_FILE, "Files", "Count", $iCount)
For $i = 0 To $iCount - 1
IniWrite($INI_FILE, "Files", $i, _GUICtrlListView_GetItemText($g_idLV, $i))
Next
EndFunc ;==>_SaveFiles
Func _SaveFiles3()
Local $iCount = _GUICtrlListView_GetItemCount($g_idLV)
IniWrite($INI_FILE, "Files", "Count", $iCount)
For $i = 0 To $iCount - 1
IniWrite($INI_FILE, "Files", $i, _GUICtrlListView_GetItemText($g_idLV, $i))
Next
EndFunc ;==>_SaveFiles
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $tab
; отображает кликнутую вкладку
WinSetTitle($Gui, "", "Вкладки (Tab) в GUI, текущая " & GUICtrlRead($tab))
Case $iCombo
GUICtrlSetStyle(-1, $LVS_ICON)
EndSwitch
WEnd