NO

Author Topic: Macros get expanded in the Resource file  (Read 3810 times)

Snowman

  • Guest
Macros get expanded in the Resource file
« on: June 26, 2015, 09:55:35 AM »
I am using Pelles C version 8.00.60 on Windows XP 32-bit.

In short:
Macros that are used in the .RC file get expanded when the Resource is edited inside the Pelles C IDE.

More detail:
I am programming a dialog-based application and I want to have an About box showing version, build date and copyright. My program already has this information in the Resource and I want to use it.

The crazy way is to retrieve that information when the program runs, by calls to:
  • FindResource()
  • LoadResource()
  • VerQueryValue()

The sane way is to use a header file defining the string literals that are then used in the Resource. That header file can then be reused in the source code, keeping everything straightforward and simple.

This is the way I've chosen but Pelles C keeps expanding the macros in the Resource, forcing me to write-protect the .RC file.
Here is a listing of a sample Resource file, followed by the auto-modified one when I added OriginalFilename in Pelles C:

Code: [Select]
// RESOURCE SCRIPT generated by "Pelles C for Windows, version 8.00".

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "Version.h"

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x3F
FILEFLAGS 0x0
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
{
  BLOCK "StringFileInfo"
  {
    BLOCK "040904B0"
    {
      VALUE "Comments", ViComments
      VALUE "CompanyName", ViCompanyName
      VALUE "FileDescription", ViFileDescription
      VALUE "FileVersion", ViFileVersion
      VALUE "LegalCopyright", ViLegalCopyright
      VALUE "ProductVersion", ViProductVersion
    }
  }
  BLOCK "VarFileInfo"
  {
    VALUE "Translation", 0x409, 0x4B0
  }
}



Code: [Select]
// RESOURCE SCRIPT generated by "Pelles C for Windows, version 8.00".

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "Version.h"

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x3F
FILEFLAGS 0x0
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
{
  BLOCK "StringFileInfo"
  {
    BLOCK "040904B0"
    {
      VALUE "Comments", "useless program\0"
      VALUE "CompanyName", "Frobtech\0"
      VALUE "FileDescription", "useless file\0"
      VALUE "FileVersion", "0.0.0.0\0"
      VALUE "LegalCopyright", "(c) 1990 Marge Simpson\0"
      VALUE "OriginalFilename", "ruin_my_res.exe\0"
      VALUE "ProductVersion", "1.1.1.1\0"
    }
  }
  BLOCK "VarFileInfo"
  {
    VALUE "Translation", 0x409, 0x4B0
  }
}



Suggested fix:
Make it so that macros aren't expanded in .RC files.

Attached below is a small project that can be used to check this problem.

Jacky

  • Guest
Re: Macros get expanded in the Resource file
« Reply #1 on: March 31, 2016, 11:37:55 AM »
Hey, I meet the problem too. I used the macro name defined in dlgs.h such as chx1, chx2, chx3, cmb1, cmb2, cmb3, etc, all of them are converted to decimal numbers after editing the resource script (.rc) though Pelles C resource editor.

Grincheux

  • Guest
Re: Macros get expanded in the Resource file
« Reply #2 on: April 03, 2016, 05:19:40 PM »
I also met this problem See my post