|
-
Aug 16th, 2000, 04:47 PM
#1
Thread Starter
Hyperactive Member
Would it be easy to extract an icon from a file, then add it to an ImageList for use by TreeView control?
-
Aug 16th, 2000, 05:05 PM
#2
Frenzied Member
Yep, it is, just download a control from vbaccelerator.com called Icon Extractor and extract the icon, then you could put it in any Imagelist like you always did.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Aug 16th, 2000, 05:27 PM
#3
Thread Starter
Hyperactive Member
Note to self: be more specific in VB forums.
I mean during execution of my application.
-
Aug 16th, 2000, 05:57 PM
#4
transcendental analytic
Ok, you need to have a treeview, a imagelist and a picturebox (hidden with autoredraw on)
Code:
'In a module
Declare Function ExtractIconEx Lib "shell32" Alias "ExtractIconExA" (ByVal lpszFile As String, ByVal nIconIndex As Long, phIconLarge As Long, phIconSmall As Long, ByVal nIcons As Long) As Long
Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hicon As Long) As Long
Function GetIconsFromFile(Filename$)
Dim hIcons()
ReDim hIcons(ExtractIconEx(Filename, -1, ByVal 0&, ByVal 0&, 0))
If UBound(hIcons) = 0 Then Exit Function Else ReDim Preserve hIcons(UBound(hIcons) - 1)
ExtractIconEx Filename, 0, hIcons(0), ByVal 0&, 10
GetIconsFromFile = hIcons
End Function
Function GetIconFromFile&(Filename$, Optional index&)
ExtractIconEx Filename, index, GetIconsFromFile, ByVal 0&, 10
End Function
'In code
DrawIcon picture1.hdc, 0, 0, GetIconFromFile(YourFilepath)
ImageList1.ListImages.Add , "YourIcon", picture1.Picture
TreeView1.Nodes.Add , , , "Caption", "YourIcon"
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
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
|