Jump to content

Imagelist Overlay Images

Recommended Posts

I'm making a ListView control that needs to have one of its icons display an overlay image.

I'm still a beginner, so I'm sure there's something that I'm just not grasping.

Basically, the test part of my code that deals with this image list begins with:


_GUIImageList_AddIcon($image32,@SystemDir&"/netshell.dll",74,1) ; default overlay icon (little checkmark)

_GUIImageList_AddIcon($image32,"D:/Emulators/SNES/Snes9X.exe",0,1) ; a random icon (for now)


And then I just want to (for the moment) show this image on my window:


_GUIImageList_DrawEx($image32,1,$hDC,3,60,0,0,$CLR_NONE,0,0x100) ; 0x100=1<<8


But the overlay doesn't appear.

Link to comment
Share on other sites

Yeah, I can get the icons themselves to appear. When I use this function, it returns True and @error is empty. Windows just doesn't seem to want to display one over the other.

Here's the relevant section from the GuiImageList.au3 include file:

; #NO_DOC_FUNCTION# =============================================================================================================
; Name...........: _GUIImageList_SetOverlayImage
; Description ...: Adds a specified image to the list of images to be used as overlay masks
; Syntax.........: _GUIImageList_SetOverlayImage($hWnd, $iImage, $iOverlay)
; Parameters ....: $hWnd        - Handle to the control
;                  $iImage      - The zero-based index of an image in the himl image list
;                  +This index identifies the image to use as an overlay mask
;                  $iOverlay    - The one-based index of the overlay mask
; Return values .: Success      - True
;                  Failure      - False
; Author ........: Gary Frost (gafrost)
; Modified.......:
; Remarks .......: An image list can have up to four overlay masks in (comctl32.dll) version 4.70 and earlier
;                  and up to 15 in version 4.71. The function assigns an overlay mask index to the specified image.
;                  An overlay mask is an image drawn transparently over another image.
;                  To draw an overlay mask over an image, call the _GUIImageList_Draw or _GUIImageList_DrawEx function.
;                  A call to this method fails and returns $E_INVALIDARG unless the image list is created using a mask.
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _GUIImageList_SetOverlayImage($hWnd, $iImage, $iOverlay)
    Local $aResult = DllCall("comctl32.dll", "bool", "ImageList_SetOverlayImage", "handle", $hWnd, "int", $iImage, "int", $iOverlay)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] <> 0
EndFunc   ;==>_GUIImageList_SetOverlayImage
I checked MSDN, and this is almost a word-for-word copy of what they have online: http://msdn.microsoft.com/en-us/library/aa922149.aspx

Here's basically the other stuff that goes with it from MSDN:

An overlay image is drawn transparently over the primary image specified in the i parameter. To specify an overlay image in the fStyle parameter, use the INDEXTOOVERLAYMASK macro to shift the one-based index of the overlay image. Use the OR operator to logically combine the return value of the macro with the drawing style flags specified in the fStyle parameter. You must first specify this image as an overlay image by using the ImageList_SetOverlayImage function.
The INDEXTOOVERLAYMASK macro is defined as follows.
#define INDEXTOOVERLAYMASK(i) ((i) << 8)
It would be nice if the help file had an example for overlays, but this is still an undocumented function.
Link to comment
Share on other sites

The only other thing I can think of to try is to use _GUIImageList_Merge (another undocumented function) to merge my icon with the overlay, which will create a new image list containing the icon+overlay, copy the new image back into my image list, then delete the new image list. Repeat this an indefinite number of times and use the odd numbered items for my icons, and the even ones for icons+overlay.

I haven't tried this yet because it too probably won't work for some reason or another, and I'd rather do things the right way because the Windows API is supposed to support overlays.

Has anyone been able to successfully use overlay images with AutoIt?

Link to comment
Share on other sites

I know this is not the approach you are looking for and so have avoided posting here. If you can't get this to work using an imagelist merge or overlay you could try drawing the two icons to the same bitmap using GDI and saving as a temp image....Like I said it is a work around and likely not want you need. Good luck

Link to comment
Share on other sites

That was the first thing I did before I discovered the existence of overlay images. The problem was getting it to work in a listview control.

I guess I could just draw them directly to the window and create some DIY routines to make them behave somewhat like icons. At least then I could move on to something else.

Link to comment
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

  • Recently Browsing   0 members

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