Re: How to load bitmaps from a resource file?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Geo" <Geo@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:A6114740-4F16-482A-B209-8A028943F89A@xxxxxxxxxxxxxxxx
Hi to all,

I created a resource file in Visual C++ 6.0 that contains 3 bitmaps. It is
compiled and included in a Visual Basic 6.0 project. I can see the resource
file under the "Related Documents" of my project in the Project Group window.

I'm trying to populate an ImageCombo with these bitmaps. For this, I created
an ImageList control and I'm trying to fill it with these bitmaps by doing:


For index = 1 To 3
sImage = GetImage(index)
imgList.ListImages.add(, , LoadResPicture(sImage, vbResBitmap))
Next


Function GetImage(index As Integer) As String
Dim sImage As String

Select Case index
Case 1
sImage = "IDB_CIRCLE" 'The ID of the bitmap resource in VC++
Case 2
sImage = "IDB_SQUARE" 'The ID of the bitmap resource in VC++
Case 3
sImage = "IDB_TRIANGLE" 'The ID of the bitmap resource in VC++
End Select

GetImage = sImage
End Function


Please note that my code worked fine when I was loading the bitmaps from a
hard-coded path (instead of trying to load them from the resource file) using:
LoadPicture(sPath + sImage + sExt) 'sExt = ".bmp"



When you created the resource file, did you actually use strings for the indexes? Are those IDB_ strings actually supposed to be constants for numeric values? Have you tried creating your resource file using VB's Resource Editor AddIn?

--
Mike
Microsoft MVP Visual Basic

.



Relevant Pages

  • Re: Paperclip-icon in preview pane disappeared
    ... >>presenting the icon. ... >>In case the problem is instead just in the resource file ... > The number of the bitmaps fit to the numbers posted by ... The bitmaps aren't corrupt and everything seems to be ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Add my own bitmaps into a resource file?
    ... I want to use a resource file to load my own bitmaps. ... I have the version 3.0 Image editor. ... I've managed to do it by creating a new bmp to the size of my original then ...
    (comp.lang.pascal.delphi.misc)
  • Add my own bitmaps into a resource file?
    ... I want to use a resource file to load my own bitmaps. ... using loadfromfile but want to get away from that. ...
    (comp.lang.pascal.delphi.misc)
  • Re: ToolBox Bitmap
    ... Did that for both controls(removed the resource file and added both bitmaps (as embedded)), but I'm still getting the default bitmaps. ... Here's the actual code for one of the controls: ... only the default icons are displayed. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Longest line of C#; isolated storage
    ... Basically, in VS.NET, add a Resource file to your project. ... Double-click on the resource file and then copy and paste your XML into the value column and add a name. ... If you copied and pasted the XML into a string, then it will expose a property with the name specified in the designer. ... Isolated storage was mentioned by you initially in your post, and I mentioned it again. ...
    (microsoft.public.dotnet.languages.csharp)