Sign in to follow this  
Followers 0
bourny

Icon number mismatch on dll`s

4 posts in this topic

I am trying to place a range of icons in my Gui and have discovered inconsistent results on the icon numbers that I reference on the web against what is displayed on the GUI.  Has anyone else seen this behaviour and what am I doing wrong.

In the example below the red cross works but the green tick gives back a magnifying glass.  I have also noticed the icon numbers I actually want will only appear correct for most if I reduce the shell32 number by 1.  Its as if the document I am referencing is out by one all the way but this still does not account for the magnifying glass instead of a green tick

Example code 

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui, $idListview, $hImage
    Local $iStylesEx = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    $hGui = GUICreate("ImageList AddIcon", 400, 300)
    $idListview = _GUICtrlListView_Create($hGui, "", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ;; Load images
    ;$hImage = _GUIImageList_Create(16, 16, 5, 3)
    ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 3)
    ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    ;_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    ;_GUICtrlListView_SetImageList($idListview, $hImage, 1)


     $hImage = _GUIImageList_Create(16, 16, 5, 1)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll ", 22) ; Mag Glass   0
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll ", 131) ;Red Cross    1
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll ", 166) ;Pie        2
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll ", 238) ; Running      3
    _GUIImageList_AddIcon($hImage, @SystemDir & "\ieframe.dll ", 72) ;Paused Backup Schedule 4
    _GUIImageList_AddIcon($hImage, @SystemDir & "\inetcplc.dll ", 41) ;green tick       5
    _GUIImageList_AddIcon($hImage, @SystemDir & "\ieframe.dll ", 57) ;Failed to rport;    6
    _GUIImageList_AddIcon($hImage, @SystemDir & "\ieframe.dll ", 44) ;Schedule not today    7
    _GUICtrlListView_SetImageList($idListview, $hImage, 1) ;setting last value to 2 allows cycling of images





    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 120)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 1)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 3)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 3)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 5)
    _GUICtrlListView_AddItem($idListview, "Row 4: Col 1", 5)
    _GUICtrlListView_AddItem($idListview, "Row 5: Col 1", 5)
    _GUICtrlListView_AddSubItem($idListview, 4, "Row 5: Col 2", 1, 5)
    _GUICtrlListView_AddItem($idListview, "Row 6: Col 1", 5)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 2", 1, 5)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 3", 2, 6)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

 

Share this post


Link to post
Share on other sites



If I do not mix the dll`s it seems to behave itself.  I will have a play around to create multiple image lists using the same dll icon set in each image list control.

 

Share this post


Link to post
Share on other sites

To complicate even further  If I want a green tick in shell32.dll it is number 301 on windows 8 and windows 7 is shell32.dll is completely different icon.  This means I will need loads of @osversion in the script.

 

 Any ideas on how to harmonize this or simply grab and run with the icons I need and not reference dll files.  I would prefer the dll approach as this means not having to unpack dump out file son disk to reference as an image link.

 

Share this post


Link to post
Share on other sites

Going for external files as its more consistent

Grabbed the icons from dll using ResourcesExtract http://www.nirsoft.net/utils/resources_extract.html

 

#include <WindowsConstants.au3>


#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>

Global $hGui, $listview, $hImage
Global $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

$hGui = GUICreate("ImageList AddIcon", 400, 300)
$listview = _GUICtrlListView_Create($hGui, "", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)
GUISetState()

$hImage = _GUIImageList_Create(16, 16, 5, 1)
_GUIImageList_AddIcon($hImage, "f:\icon2\ieframe_18211.ico", 0 ) ;tick
_GUIImageList_AddIcon($hImage, "f:\icon2\ieframe_18212.ico", 0 ) ;cross
_GUIImageList_AddIcon($hImage, "f:\icon2\ieframe_20782.ico", 0 ) ;exclaim
_GUIImageList_AddIcon($hImage, "f:\icon2\ieframe_31026.ico", 0 ) ;broken paper

_GUICtrlListView_SetImageList($listview, $hImage, 1)
_GUICtrlListView_AddColumn($listview, "Column 1", 120)
_GUICtrlListView_AddItem($listview, "Row 1: Col 1", 0)
_GUICtrlListView_AddItem($listview, "Row 2: Col 1", 1)
_GUICtrlListView_AddItem($listview, "Row 3: Col 1", 2)
_GUICtrlListView_AddItem($listview, "Row 4: Col 1", 3)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()

Exit

 

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