|
-
Jun 5th, 2002, 04:45 AM
#1
Thread Starter
Bouncy Member
-
Jun 5th, 2002, 05:01 AM
#2
Frenzied Member
Add a picture to ImageList using ListImages collection and then use its key when adding item to the listview or using its icon properties..
-
Jun 5th, 2002, 05:16 AM
#3
Thread Starter
Bouncy Member
yes but how do i add it to the imagelist???
i cant use LoadPicture can i...
-
Jun 5th, 2002, 10:59 AM
#4
Thread Starter
Bouncy Member
-
Jun 6th, 2002, 01:27 AM
#5
Frenzied Member
Hope this will help..
First set the ImageLists for smallicons, largeicons at designtime..
VB Code:
Private Sub Command1_Click()
ImageList1.ListImages.Add , "pic1", LoadPicture("c:\windows\clouds.bmp")
ListView1.ListItems.Add , "sdf", "There", "pic1", "pic1"
End Sub
-
Jun 6th, 2002, 03:10 AM
#6
Thread Starter
Bouncy Member
nope, not at all
-
Jun 6th, 2002, 04:33 AM
#7
Banned
This sub comes from an app of mine which lists all items on the desktop in a listview and adds their icons.
It uses a function with Dir() to loop through the desktop, which isn't added here.
Hopes it helps. I don't have more time to specify it for your problem so I just post the entire sub:
VB Code:
Public Sub DisplayIcons(Filename As String)
Dim fname As String
fname = Filename
Dim hImgSmall As Long
Dim hImgLarge As Long
Dim info1 As String
Dim info2 As String
On Local Error GoTo cmdLoadErrorHandler
hImgSmall = SHGetFileInfo(fname$, 0&, shinfo, Len(shinfo), BASIC_SHGFI_FLAGS Or SHGFI_SMALLICON)
info1 = Left$(shinfo.szDisplayName, InStr(shinfo.szDisplayName, Chr$(0)) - 1)
info2 = Left$(shinfo.szTypeName, InStr(shinfo.szTypeName, Chr$(0)) - 1)
PicSmall.Picture = LoadPicture()
PicSmall.AutoRedraw = True
ImageList_Draw hImgSmall&, shinfo.iIcon, PicSmall.hDC, 0, 0, ILD_TRANSPARENT
PicSmall.Picture = PicSmall.Image
imlSmall.ListImages.Add ItemCount, , PicSmall.Picture
hImgLarge = SHGetFileInfo(fname, 0&, shinfo, Len(shinfo), BASIC_SHGFI_FLAGS Or SHGFI_LARGEICON)
info1 = Left$(shinfo.szDisplayName, InStr(shinfo.szDisplayName, Chr$(0)) - 1)
info2 = Left$(shinfo.szTypeName, InStr(shinfo.szTypeName, Chr$(0)) - 1)
PicLarge.Picture = LoadPicture()
PicLarge.AutoRedraw = True
ImageList_Draw hImgLarge&, shinfo.iIcon, PicLarge.hDC, 0, 0, ILD_TRANSPARENT
PicLarge.Picture = PicLarge.Image
imlLarge.ListImages.Add ItemCount, , PicLarge.Picture
Exit Sub
cmdLoadErrorHandler:
pixLarge.Picture = LoadPicture()
End Sub
-
Jun 6th, 2002, 04:36 AM
#8
Banned
Oops.
Here is some API stuff that you'll probably need 
VB Code:
Public Const MAX_PATH = 260
Public Const SHGFI_DISPLAYNAME = &H200
Public Const SHGFI_EXETYPE = &H2000
Public Const SHGFI_SYSICONINDEX = &H4000 'system icon index
Public Const SHGFI_LARGEICON = &H0 'large icon
Public Const SHGFI_SMALLICON = &H1 'small icon
Public Const ILD_TRANSPARENT = &H1 'display transparent
Public Const SHGFI_SHELLICONSIZE = &H4
Public Const SHGFI_TYPENAME = &H400
Public Const BASIC_SHGFI_FLAGS = SHGFI_TYPENAME _
Or SHGFI_SHELLICONSIZE Or SHGFI_SYSICONINDEX _
Or SHGFI_DISPLAYNAME Or SHGFI_EXETYPE
Public Type SHFILEINFO
hIcon As Long
iIcon As Long
dwAttributes As Long
szDisplayName As String * MAX_PATH
szTypeName As String * 80
End Type
Public 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
Public Declare Function ImageList_Draw Lib "comctl32.dll" _
(ByVal himl&, ByVal i&, ByVal hDCDest&, _
ByVal x&, ByVal y&, ByVal flags&) As Long
Public shinfo As SHFILEINFO
-
Jun 6th, 2002, 04:39 AM
#9
Banned
It uses 2 pictureboxes and 2 imagelists.
I use it like this:
VB Code:
DisplayIcons LoadFiles '=filename
ListView1.ListItems.Add ItemCount, , LoadFiles, ItemCount, ItemCount
I've got to go now. If you have more questions about it:
I'll be back!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|