Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Image to ImageList

Status
Not open for further replies.

rhinoman

Programmer
Aug 18, 2001
13
AU
I would like to instead of adding a new image from a file (working code example below) add the image from a Resource File in VB6. This will make my app self contained pretty much.

Thanks for any tips,

Graeme Anderson

Code:
Const MAX_PATH = 260
Const NIF_ICON = &H2
Const SHGFI_ICON = &H100
Const SHGFI_LARGEICON = &H0
Const SHGFI_SMALLICON = &H1

 Private Type SHFILEINFO
        hIcon As Long
        iIcon As Long
        dwAttributes As Long
        szDisplayName As String * MAX_PATH
        szTypeName As String * 80
 End Type


Private Declare Function ImageList_AddIcon Lib "COMCTL32" (ByVal himl As Long, ByVal hIcon As Long) As Long
Private Declare Function SHGetFileInfo Lib "shell32.dll" Alias "SHGetFileInfoA" (ByVal pszPath As String, ByVal dwFileAttributes As Long, psfi As SHFILEINFO, ByVal cbFileInfo As Long, ByVal uFlags As Long) As Long


Function AddIcon(ByVal FileName As Variant)
 Dim hList As Long
 Dim Info As SHFILEINFO
 Dim a As Long, b As Long
  hList = SHGetFileInfo(FileName, 0, Info, 352, SHGFI_ICON Or SHGFI_LARGEICON)
  a = ImageList_AddIcon(dxSideBar1.GetImageListByName("dxLImages"), info.hicon)
  hList = SHGetFileInfo(FileName, 0, Info, 352, SHGFI_ICON Or SHGFI_SMALLICON)
  b = ImageList_AddIcon(dxSideBar1.GetImageListByName("dxSImages"), info.hicon)
  AddIcon = Array(a, b)
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top