Sign in to follow this  
Followers 0
PioRey

Get icon for a listview

11 posts in this topic

Hi to all,

Just want to ask if anyone knows how to get the icon from a listview? I've attached the file in here.

The image has a listview which has an icon on a column, how will I be able to get that icon and put it into another listview within the application?

appreciate any help I can get..

Thanks.

post-58910-12801121633404_thumb.jpg

Share this post


Link to post
Share on other sites



I think the question is a little confusing, or lacking context... have you looked at _GUIImageList_GetIcon() ?

Share this post


Link to post
Share on other sites

I think the question is a little confusing, or lacking context... have you looked at _GUIImageList_GetIcon() ?

...after using _GUICtrlListView_GetImageList() to get the image list handle for use in _GUIImageList_GetIcon().

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Can you post a sample script to start with? Thanks.

Share this post


Link to post
Share on other sites

Please help me on this..... have been searching the answer for days..

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Hi, tried that functions but what I need is get the icons used from a Listview control in the external app.

I've used this functions and seems not working for me

; returns the ImageList used on the Listview control on the external app

$hImageList = _GUICtrlListView_GetImageList($hListview, 0)

; Try this one and returns 0??? Why?

_GUIImageList_GetImageCount($hImageList)

Thanks.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Never tried that, maybe _GUIImageList_Duplicate() works, where $hWnd is the handle of the source listview. Then use _GUIImageList_GetIcon() to extract the needed icons.

Edited by KaFu

Share this post


Link to post
Share on other sites

Tried that one but no luck. I've used the _GUICtrlListView_GetImageList and it returns the handle value but using the _GUIImageList_GetImageCount it returns 0, can you please help me? Thanks.

Share this post


Link to post
Share on other sites

Posting the codes below...

;======================================
; Helper Files
;
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <ListviewConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiTreeView.au3>
;======================================
; Explicit variable declaration
Opt('MustDeclareVars', 1)


;======================================
; Variables
;
Global Const $APPNAME = "Resource Updating Manager"
Global Const $hTreeview = ControlGetHandle($APPNAME, "", "[CLASS:WindowsForms10.SysTreeView32.app.0.378734a; NAME:MainTree]")
Global Const $hListview = ControlGetHandle($APPNAME, "", "[CLASS:WindowsForms10.SysListView32.app.0.378734a; NAME:ComputersList]")
Global Const $SMALL_ICONS = 1
;======================================


; Script starts here
_Main()


Func _Main()
    Local $hImageList, $frmSample, $ListView1
    Local $nRow, $nCol
    Local $tmpImageList, $hIcons[2], $lIndex

    ; Draw form
    $frmSample = GUICreate("Sample", 255, 300, 192, 114)
    $ListView1 = GUICtrlCreateListView("", 8, 8, 234, 262, $LVS_REPORT)

    $hImageList = _GUICtrlListView_GetImageList($hListview, 1) ; Returned value = 0x00193500

    _OutputToMsgbox(_GUIImageList_GetImageCount($hImageList)) ; Returned value = 0 is this correct??? 

    GUISetState(@SW_SHOW)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc

Func _OutputToMsgbox($nMsg)
    MsgBox(0, "", $nMsg)
EndFunc

Share this post


Link to post
Share on other sites

Here's your belated chastisement for double-posting... :blink:

As posted in the other topic, my attempt at a demo reading the icon details from an explorer window's listview failed in similar fashion. This makes me wonder if you can do this with a listview not owned by your script's process.

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0