vbAccelerator - Contents of code file: frmIlsEffects.frm

VERSION 5.00
Begin VB.Form frmIlsEffects 
   BackColor       =   &H80000005&
   Caption         =   "Alpha Icon Test"
   ClientHeight    =   5295
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   7845
   Icon            =   "frmIlsEffects.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   5295
   ScaleWidth      =   7845
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   495
      Left            =   180
      TabIndex        =   0
      Top             =   4680
      Width           =   1095
   End
End
Attribute VB_Name = "frmIlsEffects"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Type IMAGELISTDRAWPARAMS
    cbSize As Long
    hIml As Long
    i As Long
    hdcDst As Long
    x As Long
    y As Long
    cX As Long
    cY As Long
    xBitmap As Long
    yBitmap As Long
    rgbBk As Long
    rgbFg As Long
    fStyle As Long
    dwRop As Long
    fState As Long
    Frame As Long
    crEffect As Long
End Type

Public Enum ImageListStateConstants
   ILS_NORMAL = &H0& 'The image state is not modified.
   ILS_GLOW = &H1& ' Adds a glow effect to the icon, which causes the icon to
    appear to glow with a given color around the edges. The color for the glow
    effect is passed to the IImageList::Draw method in the crEffect member of
    IMAGELISTDRAWPARAMS.
   ILS_SHADOW = &H2& 'Adds a drop shadow effect to the icon. The color for the
    drop shadow effect is passed to the IImageList::Draw method in the crEffect
    member of IMAGELISTDRAWPARAMS.
   ILS_SATURATE = &H4& ' Saturates the icon by increasing each color component
    of the RGB triplet for each pixel in the icon. The amount to increase is
    indicated by the frame member in the IMAGELISTDRAWPARAMS method.
   ILS_ALPHA = &H8& ' Alpha blends the icon. Alpha blending controls the
    transparency level of an icon, according to the value of its alpha channel.
    The value of the alpha channel is indicated by the frame member in the
    IMAGELISTDRAWP
End Enum

Private Declare Function ImageList_DrawIndirect Lib "COMCTL32.DLL" ( _
    pimldp As IMAGELISTDRAWPARAMS) As Long
    
Private Const ILD_IMAGE = &H20&
Private Const ILD_PRESERVEALPHA = &H1000&
Private Const CLR_NONE = -1

Private m_cIml As cVBALImageList

Private Sub loadIcons()
Dim sDir As String
Dim sStartDir As String
   sStartDir = App.Path
   If (Right$(sStartDir, 1) <> "\") Then sStartDir = sStartDir & "\"
   sDir = Dir(sStartDir & "*.ico", vbNormal)
   Do While (sDir <> "")
      m_cIml.AddFromFile sStartDir & sDir, IMAGE_ICON
      sDir = Dir
   Loop
End Sub

Private Sub Command1_Click()
Dim i As Long
Dim idp As IMAGELISTDRAWPARAMS
   Me.Cls
   
   idp.cbSize = Len(idp)
   idp.hIml = m_cIml.hIml
   idp.hdcDst = Me.hdc
   idp.rgbBk = CLR_NONE
   idp.fState = ILD_PRESERVEALPHA Or ILD_IMAGE
   
   For i = 1 To m_cIml.ImageCount
      
      ' draw standard:
      m_cIml.DrawImage i, Me.hdc, (i - 1) * (m_cIml.IconSizeX + 4) + 4, 4
      
      idp.x = (i - 1) * (m_cIml.IconSizeX + 4) + 4
      idp.y = 4
      idp.i = i - 1
      
      ' saturate (only ever seems to result in unsaturated image?)
      idp.y = idp.y + (m_cIml.IconSizeY + 4)
      idp.fState = ILS_SATURATE
      idp.Frame = -128
      ImageList_DrawIndirect idp
            
      ' glow (does not appear to work)
      'idp.x = idp.x + (m_cIml.IconSizeX + 2)
      'idp.fState = ILS_GLOW
      'idp.crEffect = &HFFFFFF
      'ImageList_DrawIndirect idp
      
      ' shadow (does not appear to work)
      'idp.x = idp.x + (m_cIml.IconSizeX + 2)
      'idp.fState = ILS_SHADOW
      'idp.crEffect = &HFF0000
      'ImageList_DrawIndirect idp
      
      ' alpha (does not appear to work)
      'idp.x = idp.x + (m_cIml.IconSizeX + 2)
      'idp.fState = ILS_ALPHA
      'idp.Frame = 128
      'ImageList_DrawIndirect idp
      
      ' draw selected:
      m_cIml.DrawImage i, Me.hdc, (i - 1) * (m_cIml.IconSizeX + 4) + 4, 4 +
       (m_cIml.IconSizeY + 4) * 2, True
      
      ' draw cut:
      m_cIml.DrawImage i, Me.hdc, (i - 1) * (m_cIml.IconSizeX + 4) + 4, 4 +
       (m_cIml.IconSizeY + 4) * 3, , True
   
   
   Next i
End Sub

Private Sub Form_Load()
   Dim sPic As String
   sPic = App.Path
   If (Right$(sPic, 1) <> "\") Then sPic = sPic & "\"
   sPic = sPic & "droplets.jpg"
   Set Me.Picture = LoadPicture(sPic)
   
   Set m_cIml = New cVBALImageList
   m_cIml.IconSizeX = 48
   m_cIml.IconSizeY = 48
   m_cIml.ColourDepth = ILC_COLOR32
   m_cIml.Create
   
   loadIcons
   
End Sub