Several icons in an EXE

Share your advanced PureBasic knowledge/code with the community.
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Several icons in an EXE

Post by Droopy »

To have an EXE with severals icons
Create a Text file with RC extension and include it as Icon Resource type
You can use absolute or relative Path
Example :

Code: Select all

            ICONE1 ICON "1.ico"
            ICONE2 ICON "2.ico"
If you don't specify an icon in the compiler option, the first icon is used by default .
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

>> You can use absolute or relative Path
the PB-Ide doesn't found the Resource by relative Path, only jaPBe can do this.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

You'r in the right :D

JAPBE can use absolute or relative Path
Example :
ICONE1 ICON "1.ico"
ICONE2 ICON "2.ico"
PB-IDE must use absolute path
Example :
ICONE1 ICON "D:\\1.ico"
ICONE2 ICON "D:\\2.ico"
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Sorry for the stupid question :roll: , but how do you include a resource file in a PB project? This is something I've not required before.

Thanks.
I may look like a mule, but I'm not a complete ass.
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

JAPBE : Project Options / Resources tab
PB-IDE : Compiler Options / Resources tab
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Doh!

I think this combined with your other recent post in this section will prove very useful.

Thank you.
I may look like a mule, but I'm not a complete ass.
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post by NoahPhense »

So does this mean that we can use a .rc file to contain the file information?

- np
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

Code: Select all

ICONE1 ICON "D:\\1.ico" 
ICONE2 ICON "D:\\2.ico"
is a content of an RC file
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

NoahPhense wrote:So does this mean that we can use a .rc file to contain the file information?

- np
for example, you can use this:

Code: Select all

1 VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
{
  BLOCK "StringFileInfo"
  {
    BLOCK "040704b0"
    {
      VALUE "ProductName", "Myprogram.exe\0"
      VALUE "ProductVersion", "1.0\0"
      VALUE "FileVersion", "1.0.0.1\0"
      VALUE "FileDescription", "\0"
      VALUE "InternalName", "Myprogram.exe\0"
      VALUE "OriginalFilename", "Myprogram.exe\0"
      VALUE "LegalCopyright", "© 2005 by NoahPhense\0"
    }
  }
  BLOCK "VarFileInfo"
  {
    VALUE "Translation", 0x0407, 0x4b0
  }
}
you can also added icons and other resources
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Armoured
Enthusiast
Enthusiast
Posts: 365
Joined: Mon Jan 26, 2004 11:39 am
Location: ITALY
Contact:

Post by Armoured »

Hi
I want to add a version resource from the command line to a program. First I have made a file called "version.rc" with the text of NoaPhense:

Code: Select all

1 VERSIONINFO 
FILEVERSION 1,0,0,1 
PRODUCTVERSION 1,0,0,1 
FILEOS VOS_NT_WINDOWS32 
FILETYPE VFT_APP 
{ 
  BLOCK "StringFileInfo" 
  { 
    BLOCK "040704b0" 
    { 
      VALUE "ProductName", "Myprogram.exe\0" 
      VALUE "ProductVersion", "1.0\0" 
      VALUE "FileVersion", "1.0.0.1\0" 
      VALUE "FileDescription", "\0" 
      VALUE "InternalName", "Myprogram.exe\0" 
      VALUE "OriginalFilename", "Myprogram.exe\0" 
      VALUE "LegalCopyright", "© 2005 by NoahPhense\0" 
    } 
  } 
  BLOCK "VarFileInfo" 
  { 
    VALUE "Translation", 0x0407, 0x4b0 
  } 
}
And finally I have used the compiler from the command line with the option /resource "c:version.rc" but I have this error:

Polink fatal error file not found "PureBasic.res" :cry:

Why?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Use a batchfile like this:
"D:\Programmieren\PureBasic4\Compilers\porc.exe" "Version.rc" ; change Path
In your Application import the compiled Resource like:

Code: Select all

Import "Version.res" : EndImport
I hope this info is useful for you
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Armoured
Enthusiast
Enthusiast
Posts: 365
Joined: Mon Jan 26, 2004 11:39 am
Location: ITALY
Contact:

Post by Armoured »

Hi ts-soft and thanks for your help :)
chen
Enthusiast
Enthusiast
Posts: 338
Joined: Fri Dec 23, 2005 2:20 pm
Location: Quebec, Canada
Contact:

Post by chen »

Resources files are only for Windows... in accordance to the manual
Since Resources are a specific to the Windows platform only, PB does not include a Library to manage them and they are not further documented here. See documentation on the Windows API and resources for more information.
Then, for people working in cross-platform (or thinking on) is not. :wink:
User avatar
Michael Vogel
Addict
Addict
Posts: 2808
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Several icons in an EXE

Post by Michael Vogel »

Some of my programs have more than one icon in it's exe file -- it's not easy to keep such IDE projects portable (on my USB stick), because all icon files need an absolute path :cry:...

So this is a kind of feature request or, at least, a poll which possibilities would allow an easier management for resources. So what kind of improvements could be done, let's start...
• the IDE should allow to add more than only one icon (the best way, fred have to do the job)
• a selfmade tool plays a kind of preprocessor (see below) and adapt pathes, if necessary (slows done each compilation)
• any other ideas?

Michael


___
Principle of Portable-RC.pb
- read source file
- check, if "; AddResource" is present
- <NO>: quit
- <YES>: read resource file, replace vars like %SOURCEPATH% by real values, save backup of original text in a comment line
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Several icons in an EXE

Post by ts-soft »

Michael Vogel wrote: • any other ideas?
create a "myresource.res" with porc from your script and import this!
Post Reply