Jump to content

How to get icon in listview control


Recommended Posts

Hi to all,

I'm creating a script that will automate the process of the migration of computers from one domain into the other domain using Resource Updating Manager of Quest Migration Manager. Into the listview, I can get the values from it and store into an array, now my problem is that in that listview, an icon is in the first column of the listview and it seems I cannot get the value of that icon along with the values of that row. What I want to ask is, how will I be able to get that icon with the values in its row and add it again into the listview in a different group? I used the _GUICtrlListView_GetImageList but I keep hitting a wall. Can anyone shed some light? Thanks.

Link to comment
Share on other sites

Having a handle to the image list is only half of it. You want to know the index of the image for a particular item in the listview, which would be _GUICtrlListView_GetItemImage(). See help file.

:blink:

Edited by PsaltyDS
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
Link to comment
Share on other sites

Hi,

I can get the image index by using that function, but my problem now is whenever I used this code, it doesn't have any value

; this get the ImageList used by the Listview control of the external app.

$hImageList = _GUICtrlListView_GetImageList($hListview, 0)

; This returns 0, it seems it did not

; get any values from the ImageList that was used from

; the listview of the external app.

$hImageCount = _GUIImageList_GetImageCount($hImageList)

If I can get the image count of the imagelist control, then probably i can use the _GUIImageList_GetIcon function.

Thanks

Link to comment
Share on other sites

Actually, I failed to get my attempt at a demo to work:

#RequireAdmin

#Include <GuiListView.au3>
#Include <GuiImageList.au3>

$hWin = WinGetHandle("[CLASS:CabinetWClass; TITLE:C:\Temp]", "")
$hLV = ControlGetHandle($hWin, "", "[CLASS:SysListView32; INSTANCE:1]")
$hImgList = _GUICtrlListView_GetImageList($hLV, 1)
$iCount = _GUICtrlListView_GetItemCount($hLV)
$sMsg = "$hWin = " & $hWin & @LF & _
        "$hLV = " & $hLV & @LF & _
        "$hImgList = " & $hImgList & @LF & _
        "$iCount = " & $iCount & @LF

For $n = 0 To $iCount - 1
    $iImgIndex = _GUICtrlListView_GetItemImage($hLV, $n, 0)
    $hIcon = _GUIImageList_GetIcon($hImgList, $iImgIndex)
    $sMsg &= $n & ":  $iImgIndex = " & $iImgIndex & "; $hIcon = " & $hIcon & @LF
Next

MsgBox(64, "Test2", $sMsg)

I get all the other handles, but the image list count says 0 and the icon handles come back as 0. Also, all the image indexes are different, even when the icon is the same. I must be missing something myself. Maybe it can only query the image index owned by its own process?

:blink:

Edited by PsaltyDS
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
Link to comment
Share on other sites

Tried your code and here's my result:

$hWin = 0x000E00F0

$hLV = 0x0004012C

$hImgList = 0x000B1F68

$iCount = 3

0: $iImgIndex = 289; $hIcon = 0x00000000

$hWin = 0x000E00F0

$hLV = 0x0004012C

$hImgList = 0x000B1F68

$iCount = 3

0: $iImgIndex = 289; $hIcon = 0x00000000

1: $iImgIndex = 127; $hIcon = 0x00000000

$hWin = 0x000E00F0

$hLV = 0x0004012C

$hImgList = 0x000B1F68

$iCount = 3

0: $iImgIndex = 289; $hIcon = 0x00000000

1: $iImgIndex = 127; $hIcon = 0x00000000

2: $iImgIndex = 177; $hIcon = 0x00000000

I really can't figure out why it can't get the handle of those icons...

Still looking for the answers.

P.S.: Sorry for the double posting.. :blink:

Edited by PioRey
Link to comment
Share on other sites

Just thinking another solution... how bout this, how will I get the row of the listview (including the icon)? Passed it into a variable and use that to inject into the other listview control within that application, would that be possible? Thanks.

Edited by PioRey
Link to comment
Share on other sites

Just tried another approach... created a listview control and used the _GUICtrlListView_CopyItems function... but same problem, I can copy the text from the source application listview but without the icon :blink: . The view of the listview of the external app is in Detail and the listview that I created is in $LVS_Report.. still looking for a work around here...

Link to comment
Share on other sites

  • 2 weeks later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...