home *** CD-ROM | disk | FTP | other *** search
Visual Basic class definition | 2001-09-09 | 3.6 KB | 112 lines |
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- Persistable = 0 'NotPersistable
- DataBindingBehavior = 0 'vbNone
- DataSourceBehavior = 0 'vbNone
- MTSTransactionMode = 0 'NotAnMTSObject
- END
- Attribute VB_Name = "CSysImageList"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = False
- Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
- Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
- Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
- '-----------------------------------------------------------------------------
- ' This is a part of the BeeGrid ActiveX control.
- ' Copyright ⌐ 2000 Stinga
- ' All rights reserved.
- '
- ' You have a right to use and distribute the BeeGrid sample files in original
- ' form or modified, provided that you agree that Stinga has no warranty,
- ' obligations, or liability for any sample application files.
- '-----------------------------------------------------------------------------
- Option Explicit
- Private Const ICON_SIZE = 16
- Public hImageList As Long
-
- Private Const ICC_USEREX_CLASSES = &H200
- Private Const MAX_PATH = 260
- Private Const SHGFI_DISPLAYNAME = &H200
- Private Const SHGFI_EXETYPE = &H2000
- Private Const SHGFI_ICON = &H100
- Private Const SHGFI_SYSICONINDEX = &H4000
- Private Const SHGFI_LARGEICON = &H0
- Private Const SHGFI_SMALLICON = &H1
- Private Const SHGFI_SHELLICONSIZE = &H4
- Private Const SHGFI_TYPENAME = &H400
- Private Const BASIC_SHGFI_FLAGS = SHGFI_TYPENAME _
- Or SHGFI_SHELLICONSIZE Or SHGFI_SYSICONINDEX _
- Or SHGFI_DISPLAYNAME Or SHGFI_EXETYPE
-
- Private Type SHFILEINFO
- hIcon As Long
- iIcon As Long
- dwAttributes As Long
- szDisplayName As String * MAX_PATH
- szTypeName As String * 80
- End Type
-
- Private Type tagInitCommonControlsEx
- lngSize As Long
- lngICC As Long
- End Type
-
- Private Declare Function SHGetFileInfo Lib "shell32.dll" Alias "SHGetFileInfoA" _
- (ByVal pszPath As String, ByVal dwFileAttributes As Long, _
- psfi As SHFILEINFO, ByVal cbSizeFileInfo As Long, ByVal uFlags As Long) As Long
-
- Private Declare Function InitCommonControlsEx Lib "comctl32.dll" (iccex As tagInitCommonControlsEx) As Boolean
- Private Declare Function ImageList_GetImageCount Lib "COMCTL32" (ByVal hImageList As Long) As Long
- Private Declare Function ImageList_GetIconSize Lib "COMCTL32" (ByVal hImageList As Long, cx As Long, cy As Long) As Long
- Public Function Count() As Long
- Count = ImageList_GetImageCount(hImageList)
- End Function
-
-
-
- Public Function GetIconIndex(sFileName As String, Optional sTypeName As String) As Long
- On Error Resume Next
- Dim lHeight As Long, lWidth As Long
- Dim sfi As SHFILEINFO
-
- Call ImageList_GetIconSize(hImageList, lHeight, lWidth)
-
- If lHeight = ICON_SIZE Then
- Call SHGetFileInfo(sFileName, 0&, sfi, Len(sfi), _
- ByVal SHGFI_SMALLICON Or SHGFI_TYPENAME Or SHGFI_SYSICONINDEX)
-
- If Not IsMissing(sTypeName) Then
- sTypeName = Left(sfi.szTypeName, InStr(sfi.szTypeName, Chr(0)) - 1)
- End If
- GetIconIndex = sfi.iIcon + 1
- End If
-
- End Function
-
-
-
-
- Private Sub Class_Initialize()
- Dim sfi As SHFILEINFO
- Dim iccex As tagInitCommonControlsEx
-
- With iccex
- .lngSize = LenB(iccex)
- .lngICC = ICC_USEREX_CLASSES
- End With
- Call InitCommonControlsEx(iccex)
-
- 'Any valid file system path can be used to retrieve system image list handles.
- hImageList = SHGetFileInfo("C:\", 0&, sfi, Len(sfi), _
- ByVal SHGFI_SYSICONINDEX Or SHGFI_ICON Or SHGFI_SMALLICON)
- Debug.Print Count
- End Sub
-
-
-
-
-
-