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!

Advice for making resource dll

Status
Not open for further replies.

gmmastros

Programmer
Feb 15, 2005
14,901
US
I have approximately 800 icons I use in my app. I am trying to consolidate them in to a single dll so that I do not have slightly different versions of the icon all over the place.

I tried several things, none of which are working out well for me.

Originally, I had several forms (for categorization purposes only) with a control array of images. Each icon (256 color 16 x 16) was loaded in to an image box. I gave each image a TAG and used that to get the icon I wanted to display. This approach worked well until I noticed that my app was using approximately 4,000 GDI objects after initially loading. Eventually ran in to the 10,000 limit and kaboom!

I also tried putting the icons in to a resource file. The problem I had with this approach is that even though I used 16x16 icons, they were coming out stretched to 32x32.

I then tried using an Image list. I'm actually using multiple image lists so that I can categorize the icons. This is a little bit of an improvement, but my app is still taking up approximately 2,000 GDI objects on startup. It's also taking a lot longer to load the app.

When my app loads, I dynamically create a "ribbon bar" that has approximately 100 icons on buttons. Unfortunately, I've already distributed my app, so I would prefer to modify this dll without changing too much functionality. Currently, I pass in a string that represents the Icon I want and the dll returns an IPictureDisp for the image.

Has anyone else done something similar? What are the preferred methods here?

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
I tried that. My icons are 16 x 16. When I pull the icons out of the resource file, they are coming out 32 x 32.



-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
AH yes. Not a limitation of the resource file, more a limitation of VBs LoadResPicture function.

There's a trick we can use, leveraging the ImageList

Code:
[blue]Public Function example(icoResourceIndex As Long) As StdPicture
    ImageList1.ImageWidth = 16
    ImageList1.ListImages.Add , , LoadResPicture(icoResourceIndex, 1)
    Set example = ImageList1.ListImages(1).ExtractIcon
End Function
 
Thanks. I'll give this a try.

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
I seem to be dealing with 100's of interruptions per day lately. I am still working on it.


-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
No. Never heard of it. Looking in to that now.



-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
I created a GIF with transparency (with only 4 of my icons). It was very easy to set this up. The problem is, the transparency part is showing a black. When I load the same GIF in to an image box, it shows the transparency[!]*[/!].

[!]*[/!] What I really mean is... parts that are supposed to be transparent actually are.



-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
>The problem is, the transparency part is showing a black

The PictureClip control does not support transparency. But we can play the same trick for this as we did for the resource DLL, passing it through an ImageList control , for example:

Code:
[blue]Private Sub Command1_Click()
    PictureClip1.Cols = 2
    PictureClip1.Rows = 2
    Picture1.Picture = Iconize(PictureClip1.Picture, , vbBlack)
    Picture2.Picture = Iconize(PictureClip1.GraphicCell(1), 38, vbBlack)
End Sub

[green]' Mask represents colour that will be transparent[/green]
Public Function Iconize(srcPicture As StdPicture, Optional IconWidthPixels As Long = 0, Optional Mask As Long = 0) As StdPicture
    With ImageList2
        ImageList2.ListImages.Clear
        If IconWidthPixels = 0 Then
            .ImageWidth = ScaleX(srcPicture.Width, vbHimetric, vbPixels)
        Else
            .ImageWidth = IconWidthPixels
        End If
        .MaskColor = Mask
        .ListImages.Add , , srcPicture
        Set Iconize = .ListImages(1).ExtractIcon
    End With
End Function[/blue]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top