Hello,
I've encountered a trouble when trying to use an external resource file within a Lazarus/FPC project. Windres is unable to compile my resource file (a standard .rc text file) by default.
A basic sample:
-Add "{$R Test.rc}" to one of your unit, to include the concerned resource file to your current Lazarus/FPC project,
-Create this simple resource file (i.e. Test.rc):
MyDlg DIALOGEX 0, 0, 440, 178
CAPTION "My Title"
STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
FONT 8, "MS Sans Serif"
CLASS "MyDlgClass"
BEGIN
DEFPUSHBUTTON "&Quit", IDCANCEL, 368, 8, 64, 18, BS_DEFPUSHBUTTON | WS_TABSTOP | WS_GROUP
END
-Try to compile the Lazarus/FPC project.
Using the -vd option to compile my Lazarus/FPC project, I've got this error reported:
Calling resource compiler "C:\Lazarus\fpc\2.6.0\bin\i386-win32\windres.exe" with "--preprocessor=C:\Lazarus\fpc\2.6.0\bin\i386-win32\cpp.exe --include C:\Lazarus\fpc\2.6.0\bin\i386-win32\ -O res -o C:\WORK\INTER\ess\lib\i386-win32\Test.res C:/WORK/INTER/ess/Test.rc" as command line
windres: C:/WORK/INTER/ess/Test.rc:3: syntax error
Compiling resource C:\WORK\INTER\ess\Test.rc
According to my configuration, all the options given to the Windres utility are OK (especially the paths).
After a few investigations, it seems that, by default, Windres can't recognized the option keywords : "DIALOGEX", "CAPTION", "STYLE" ... are OK, but "DS_MODALFRAME", "IDCANCEL", "WS_TABSTOP", ... are not.
If I'm replacing the concerned option keywords by their numerical values, it's now OK:
MyDlg DIALOGEX 0, 0, 440, 178
CAPTION "My Title"
STYLE 0x80L | 0x20000L | 0xc00000L | 0x80000L
EXSTYLE 0x40000L
FONT 8, "MS Sans Serif"
CLASS "MyDlgClass"
BEGIN
DEFPUSHBUTTON "&Quit", 2, 368, 8, 64, 18, 0x1L | 0x10000L | 0x20000L
END
The other solution being also to manually include the "windres.h" to my resource file. This second solution is OK too ("windres.h" being present in my include directory, i.e. windres option "--include C:\Lazarus\fpc\2.6.0\bin\i386-win32\"):
#include "windres.h"
MyDlg DIALOGEX 0, 0, 440, 178
CAPTION "My Title"
STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
FONT 8, "MS Sans Serif"
CLASS "MyDlgClass"
BEGIN
DEFPUSHBUTTON "&Quit", IDCANCEL, 368, 8, 64, 18, BS_DEFPUSHBUTTON | WS_TABSTOP | WS_GROUP
END
Am I the only one concerned by this problem ?
BR. ChrisF
My configuration:
Windows XP SP3 32 bits
Lazarus 1.0.6
FPC 2.6.0
(No other CygWin, Mingw, ... package present)