Page 1 of 2

Please explain a resource file

Posted: Thu Apr 05, 2018 4:02 am
by bluebird
Dear Mentors

Cold you please explain what a resource file is, what it is for, how to use.

I see some .rc files in the SAMLPES but my Adobe reader cannot open them.

Thanks, I will await an explanation

Re: Please explain a resource file

Posted: Thu Apr 05, 2018 6:54 am
by dragancesu
HMG program can load images from a folder or be embedded in the program

See demo1.prg and demo2.prg/demo2.rc

Look at demo2.rc and you will see a list of what compiler should be added to the program
Test is: make compile demo1 and demo2, than erase .bmp files and run

p.s. .rc is a simple txt file

attach is now correct, please download again,

Re: Please explain a resource file

Posted: Sat Apr 07, 2018 3:59 am
by bluebird
Thanks, I see how things work.

I noticed that the rc file on my pc looks like an adobe acrobat file. However you have to open it with notepad et.al.

Re: Please explain a resource file

Posted: Tue Apr 10, 2018 7:31 pm
by bluebird
Sorry, I don't see how things work after all

If I create a file myapp.rc with
IMAGE1 BITMAP IMAGE1.BMP

How odes the build process know about the .rc file.

Also, Does the rc file have to have the same name as the application?

Lastly, what types of resouces can be included besides BMP files

Thanks

Re: Please explain a resource file

Posted: Tue Apr 10, 2018 7:57 pm
by esgici
Please make a "search" before asking question
Search in forum.png
Search in forum.png (91.28 KiB) Viewed 1760 times
search.php?keywords=resouce+file&terms= ... mit=Search

Viva HMG :D

Re: Please explain a resource file

Posted: Wed Apr 11, 2018 6:00 pm
by bluebird
The examples have not helped

I create an rc file like myprog.rc , keeping it in the same folder as the myprog.prg file

containing a list of jpgs that I use in my program like

door jpg exitdoor.jpg
window jpg baywindow.jpg

then build the application again .

If I delete the jps and run the exe just built, the jpg images do not appear.

what am i doing wrong.

Thanks

Re: Please explain a resource file

Posted: Wed Apr 11, 2018 6:22 pm
by edk
Do you refer to the jpg file name in the sources or to its resource name?
ex. PICTURE "door" or PICTURE "exitdoor.jpg" ?

Share piece of code with us.

Re: Please explain a resource file

Posted: Wed Apr 11, 2018 6:39 pm
by andyglezl
Sample...

// Using a resource file like this, you can include images,
// icons and sounds inside EXE.
//
// Resource name Resouce Type Resource FileName
// WAVERESNAME WAVE FILENAME.WAV
// Ejemplos:
//HMG JPG HMG.JPG
//imgBMP BITMAP img.BMP
//imgJPG JPG img.JPG
//imgGIF GIF img.GIF
//imgTIF TIF img.TIF
//imgPNG PNG img.PNG
//imgWMF WMF img.WMF
//imgICO ICO img.ICO
//imgCUR CUR img.CUR

Re: Please explain a resource file

Posted: Wed Apr 11, 2018 8:08 pm
by bluebird
Thanks for all the patient replies but it ain't working for me. I have seen lots of examples in the forum and samples.

In my prg file there would be images referred to with the names like exitdoor.jpg and baywindow.jpg

The example. rc file would include: name, type, filename for each item, example of 2

door jpg exitdoor.jpg
window jpg baywindow.jpg

I used the same file name for the prg / hbp file and the resource file either in the same folder as the prg or in its own
sub-folder. Neither location worked.

I would then build the exe. How does the compiler know about and find the rc file? I don't know how.

It all sounds simple but some detail is missing in my knowledge of rc file use.

Thanks friends

Re: Please explain a resource file

Posted: Wed Apr 11, 2018 9:28 pm
by edk
bluebird wrote:
Wed Apr 11, 2018 8:08 pm
In my prg file there would be images referred to with the names like exitdoor.jpg and baywindow.jpg
(...)
I would then build the exe. How does the compiler know about and find the rc file? I don't know how.
The compiler, when it finds a .rc file with the same name as .prg in the same folder, include the resources to the result file.
It is important to refer to the resource name in the sources, not to the jpg file.
Bez tytułu.jpg
Bez tytułu.jpg (136.64 KiB) Viewed 1684 times
See an example from the attachment.
BUTTON_1.7z
(2.43 KiB) Downloaded 79 times
bluebird wrote:
Wed Apr 11, 2018 8:08 pm
The example. rc file would include: name, type, filename for each item, example of 2

door jpg exitdoor.jpg
window jpg baywindow.jpg
To check, is it jpg included into your .exe, just extract your .exe file (by 7-zip), and see folder: .rsrc\JPG, if doesn't exists "door" and "window" files, you do something wrong.