Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I've upgraded a large VB6 app to VB.NET.

However, the VB6 ImageList doesn't upgrade to the .NET ImageList. That's fine - I'll just dump the same images to a new .NET ImageList. Easier said than done! I don't have the images anymore, just the old VB6 ImageList - how do I extract the images from a VB6 ImageList ?? The ImageList is working in .NET, but I need the images in a new .NET ImageList to associate with other .NET controls.

 

Here's the code I was trying to use to recover one image as a test, but the second line causes an exception:

Dim test As stdole.IPictureDisp = Me.MyVB6ImageList.ListImages(1).Picture

Dim testimage As System.Drawing.Image = VB6.IPictureDispToImage(test)

testimage.Save("C:\Temp\test", Imaging.ImageFormat.Bmp)

 

Anyone have any idea how to recover the images?

  • Leaders
Posted
I haven't used VB6 in a while, so I'm not sure, but would it be possible to just throw a few lines in the VB6 program that can loop through the images in the ImageList and save the images to a file?
[sIGPIC]e[/sIGPIC]
Posted
I haven't used VB6 in a while' date=' so I'm not sure, but would it be possible to just throw a few lines in the VB6 program that can loop through the images in the ImageList and save the images to a file?[/quote']

 

I'm trying to do that in VB.NET since the VB6 ImageList is left in the upgraded project. The code I was attempting to do this with is in the original post. The VB6.IPictureDispToImage method looked promising, but apparently it can't really convert an IPictureDisp to an Image despite it's name - once I have the image in a System.Drawing.Image then I can save it.

Posted

After some research, it appears that many people have a similar problem with the VB6.IPictureDispToImage function (leading to the "unknown image type" exception). None of the threads I found have any resolution to this.

 

Any ideas on how to get this function to work?

Posted

Joy at last !!

 

For VB6 ImageList images originating from icons, the following code works:

Dim test As stdole.IPictureDisp = Me.MyImageList.ListImages(1).Picture

Dim testicon As System.Drawing.Icon = System.Drawing.Icon.FromHandle(test.Handle)

 

Apparently that VB6.IPictureDispToImage method doesn't work when the underlying image is an icon - it would have been nice if there were any documentation to that effect!

 

Thanks anyway to anyone who spent any time thinking about this!

  • 1 year later...
Posted (edited)

Thanks. FWIW here is the C#

           
object idx = 1;   
// Image1.Image = VB6.Support.IPictureDispToImage(ImageList1.ListImages.get_Item(ref idx).Picture);
// the above statement throws "unknown image type" exception

stdole.IPictureDisp test = this.ImageList1.ListImages.get_Item(ref idx).Picture;
System.Drawing.Icon testicon = System.Drawing.Icon.FromHandle((IntPtr)test.Handle);
Image1.Image = testicon.ToBitmap();

Edited by MarkJuras

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...