Results 1 to 3 of 3

Thread: How to use resource file

  1. #1
    New Member
    Join Date
    Apr 12
    Posts
    13

    How to use resource file

    I just learned that using a resource file is the way to go if you want to use bmp pictures in your project (among other file types).
    I see a ton of info on how to load a file from a resource file, but Nothing about how to add a bmp (for instance) to the resource file.

    I have a resource file added called "Resource1". I see it in the project explorer.

    What is the procedure to add "C:\Temp\Mypicture.bmp" to my resource file and what would be the code to load it onto a picture box
    named "Picture1" on a form named "MyForm" when clicking a command button?

    If I can see this procedure, I can figure all the rest out.

    Thanks

  2. #2
    PowerPoster
    Join Date
    Jul 06
    Location
    Maldon, Essex. UK
    Posts
    5,134

    Re: How to use resource file

    Double Click the Resource file in the Project Explorer Window. This will open the VB Resource Editor. Look at the Menu Icons; the third from the right is 'Insert Bitmap', click on that and navigate to the file to add.

    The VB Resource Editor will add the Bitmap and an ID (eg 101- which you will use to load it later)

    Save the Resource file

    In your program:
    Code:
    Picture1.Picture = LoadResPicture(101, vbResBitmap)

  3. #3
    Frenzied Member
    Join Date
    Jan 09
    Location
    Watch Window(Shift+f9)
    Posts
    1,431

    Re: How to use resource file

    you can try the following way . by default you will not get resource editor . when you click standard.exe .just got to Add in Manager and choose vb6 Resourc Editor.and finally click on Load Behavior frame .Loaded/Unloaded .
    Code:
    Picture1.Picture = LoadResPicture(101, vbResBitmap)
    other alternate way to load same picture .using Inbuild function LoadPicture()

    Code:
    Picture1.Picture = LoadPicture("C:\Pic1.bmp")
    Last edited by firoz.raj; Aug 30th, 2012 at 08:12 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •