October 29, 2025, 03:33:22 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


HowTo : Linking extern resource created with Resource Builder?

Started by Techno, June 11, 2015, 11:46:02 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Techno

Dear support,

How can I linking my extern resource file with the extention .rc or .res to my application?.
I don't find any comments how I can do this in IWBasic v3.0 ?. Can you explean the steps with an example how I can do this

Thanks
Stephane

LarryMc

I guess you read the How-To > Projects > Add Files > Resources section of the Help file and decided not to use the built in way of adding resources to your Project. Using this built in method helps insure that everything gets named and formatted correctly. But that would be too easy.

So, if your rc file is already built.
Create your project. add your source eba/iwb source files.
Whatever you name your exe file change your rc file to the same name in the same folder
i.e.  myprog.exe  myprog.rc
and make sure all the paths to the resources are correct in your rc file

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Techno

Larry,

Its compiled as res file. How can I linked in my application?
I try this but it fails:
$INCLUDE "test.res"

Thanks
Stephane

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Techno

Quote from: LarryMc on June 12, 2015, 02:13:28 AM
Heck if I know.

How can I linked an res file in iwbasic?. Is there an option or can you add this feature to the next update of iwbasic?

Example:

$USE RES CUSTOM "sound.wav"
$USE RES SCALABLE "test.gif"
....


Thanks

Andy

Hi Techno,

Please see the attached .rc file for my main project called AutoScan.

In this .rc file - you will see items listed from numbers 303 onwards.

These are files I actually want to include in the .exe program

BUT.....

They need to be extracted onto the user's computer so my program can call / use them.

Resource 303 is a help file,
312 and 313 are text files,
the others are bitmaps my program needs.

To add these resources into the .rc file I had to use notepad and type them in.

The folder C:\\Project\\Enhanced\\ is where all my files / resources are located when building the project.

Now, when my program first runs, it calls a subroutine the extracts these files to disk.

Once these files are extracted my program can use them, for example when someone clicks on the help button my program opens the autoscanenhanced.chm file.

This file opens from the disk so it can be used.

As Larry said, you have to have the name of the resource file the same as the exe file, so my resource file is called AutoScanEnhanced.rc and the exe file is AutoScanEnhanced.exe

Your program can "extract" these resources to disk with this code:

SUB ExtractResource(id:INT, restype:INT, filename:STRING)
   BFILE f
   MEMORY m
   INT retc
    retc = 0
   if loadresource(id, restype, m)
      if openfile(f, filename, "w")=0
         retc = __write(f, m, LEN(m)-1)
         closefile f
      endif
      freemem m
   endif
   return
ENDSUB

Usage:

ExtractResource(312, 324, GETSTARTPATH+"Eula.txt")
ExtractResource(313, 324, GETSTARTPATH+"ReadMe.txt")

After that I can use the "System" command to get notepad to open them...

SYSTEM "Notepad.exe","Eula.txt"

Finally, using the above method you could add your sound.wav and gil files, in the resource file, build your .exe file and when it runs extract the files so they can be used later.

It took me a little time to understand it, but trust me it's much more simple than it looks.

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

Quote from: Techno on June 12, 2015, 02:54:53 AM
....can you add this feature to the next update of iwbasic?

Example:

$USE RES CUSTOM "sound.wav"
$USE RES SCALABLE "test.gif"
....
Not likely to happen since IWBasic has the built in feature to handle rc files very efficiently
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library