Viktor1703
AutoIT Гуру
- Сообщения
- 1,535
- Репутация
- 413
Почти все стили перепробовал, ни как не могу добиться размещения иконки и текста как на рабочем столе...
Код:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <WinAPIEx.au3>
#include <GDIPlus.au3>
#include <GuiImageList.au3>
Global $hDesk = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop", "Wallpaper")
$hForm = GUICreate("", 800, 600)
$hListView = _GUICtrlListView_Create($hForm, 'Имя|Размер|Тип|Изменён', 0, 0, 800, 600, BitOR($LVS_EDITLABELS, $LVS_REPORT, $LVS_ICON, $LVS_NOCOLUMNHEADER, $LVS_AUTOARRANGE))
_GUICtrlListView_SetColumnWidth($hListView, 0, 200)
_GUICtrlListView_SetBkImageEx($hListView, $hDesk)
$hImage = _GUIImageList_Create(32, 32, 5, 1)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -49, 1)
_GUICtrlListView_SetImageList($hListView, $hImage, 1)
_GUICtrlListView_AddItem($hListView, "Мой компьютер", 0)
GUISetState()
While 1
Switch GUIGetMsg()
Case -3
Exit
EndSwitch
WEnd
Func _GUICtrlListView_SetBkImageEx($hWnd, $sImage, $iFlags = 0, $iXOffset = 0, $iYOffset = 0)
Local $hImage, $hThumb, $hBitmap, $tLVBKIMAGE, $pLVBKIMAGE, $tMem, $pMem, $Ret, $Size
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($sImage)
$hThumb = DllCall($ghGDIPDll, "int", "GdipGetImageThumbnail", "ptr", $hImage, _
"int", _WinAPI_GetWindowWidth($hWnd), "int", _WinAPI_GetWindowHeight($hWnd), _
"ptr*", 0, "ptr", 0, "ptr", 0)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hThumb[4])
If $hBitmap Then
$iFlags = BitOR(BitAND($iFlags, BitOR($LVBKIF_FLAG_TILEOFFSET, $LVBKIF_STYLE_TILE, $LVBKIF_TYPE_WATERMARK, 0x20000000)), $LVBKIF_SOURCE_HBITMAP)
Else
$iFlags = 0
EndIf
$tLVBKIMAGE = DllStructCreate('ulong;ptr;ptr;uint;int;int')
$pLVBKIMAGE = DllStructGetPtr($tLVBKIMAGE)
DllStructSetData($tLVBKIMAGE, 1, $iFlags)
DllStructSetData($tLVBKIMAGE, 2, $hBitmap)
DllStructSetData($tLVBKIMAGE, 5, $iXOffset)
DllStructSetData($tLVBKIMAGE, 6, $iYOffset)
$Ret = _SendMessage($hWnd, 4234, 0, $pLVBKIMAGE)
_GDIPlus_ImageDispose($hThumb[4])
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_Shutdown()
Return $Ret <> 0
EndFunc