Madza91 Posted July 8, 2009 Share Posted July 8, 2009 Hello. I want to add PNG image to my ImageList for ListView Items... But I see that can be only added icons and bitmaps, why isn't possible to add png images? Or if possible, I how to do that? #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> Opt('MustDeclareVars', 1) $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $hImage, $hListView GUICreate("ListView Set Image List", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState() ; Load images $hImage = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_Add($hImage, @DesktopDir & "\favicons.png") ;~ _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($hListView, $hImage, 1) _GUICtrlListView_AddColumn($hListView, "Column 1", 100) _GUICtrlListView_AddItem($hListView, "Item 1", 0) _GUICtrlListView_AddItem($hListView, "Item 2", 1) _GUICtrlListView_AddItem($hListView, "Item 3", 2) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main *Note: You need file "favicons.png" on Desktop... Here is one: [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
KaFu Posted July 13, 2009 Share Posted July 13, 2009 (edited) This works for me: Edit: Better clean up used resources... expandcollapse popup#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <GDIPlus.au3> #include <WinAPI.au3> Opt('MustDeclareVars', 1) $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work _GDIPlus_Startup () _Main() _GDIPlus_ShutDown () Func _Main() Local $hImage, $hListView, $hBitmap, $hImagePNG GUICreate("ListView Set Image List", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState() ; Load images $hImage = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_Add($hImage, @DesktopDir & "\favicons.png") ;~ _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16)) $hBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\logo.png") $hImagePNG = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GUIImageList_Add($hImage, $hImagePNG) _GDIPlus_ImageDispose ($hBitmap) _WinAPI_DeleteObject ($hImagePNG) _GUICtrlListView_SetImageList($hListView, $hImage, 1) _GUICtrlListView_AddColumn($hListView, "Column 1", 100) _GUICtrlListView_AddItem($hListView, "Item 1", 0) _GUICtrlListView_AddItem($hListView, "Item 2", 1) _GUICtrlListView_AddItem($hListView, "Item 3", 2) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main Edited July 13, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Yashied Posted July 13, 2009 Share Posted July 13, 2009 Hello. I want to add PNG image to my ImageList for ListView Items... But I see that can be only added icons and bitmaps, why isn't possible to add png images? Or if possible, I how to do that? #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> Opt('MustDeclareVars', 1) $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $hImage, $hListView GUICreate("ListView Set Image List", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState() ; Load images $hImage = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_Add($hImage, @DesktopDir & "\favicons.png") ;~ _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($hListView, $hImage, 1) _GUICtrlListView_AddColumn($hListView, "Column 1", 100) _GUICtrlListView_AddItem($hListView, "Item 1", 0) _GUICtrlListView_AddItem($hListView, "Item 2", 1) _GUICtrlListView_AddItem($hListView, "Item 3", 2) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main *Note: You need file "favicons.png" on Desktop... Here is one: http://lh3.ggpht.com/_Vao-ccymw28/Sb4BUtvGdjI/AAAAAAAAAmQ/QcPG2lJJisY/parsix+basic-logo16*16.png But why just not save the image to BMP format? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now