Bookstore

Recent

Author Topic: Lazarus Windows : Forcing Lazarus to use custom .res file  (Read 523 times)

MISV

  • Hero Member
  • *****
  • Posts: 683
Lazarus Windows : Forcing Lazarus to use custom .res file
« on: February 16, 2020, 02:28:55 am »
I am converting a project from Delphi. Actually I am already using Lazarus on Mac, but I now contemplating changing entirely to Lazarus.

I have this in my .dpr files

{$IFDEF myms_App_Whatever1}
{$R ./resources/whatever1.res}
{$ENDIF}
{$IFDEF myms_App_Whatever2}
{$R ./resources/whatever2.res}
{$ENDIF}

These .res files define *everything* including Windows theming and whatnot.

However, it seems Lazarus on Windows ignores the above and uses its own generated resource file.... And theming on my Win10 is not applied.

While I guess I could adjust options etc. I would like to get this working. (In particular since my build process may also include commandline in future)

Any ideas on how to make this work?

trev

  • Hero Member
  • *****
  • Posts: 524
  • Former Delphi 1-7 and 10.2 User
o Lazarus v2.1.0 r62775, FPC v3.3.1 r44289, macOS 10.14.6 (with sup update), Xcode 10.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0 (Parallels VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

MISV

  • Hero Member
  • *****
  • Posts: 683
Re: Lazarus Windows : Forcing Lazarus to use custom .res file
« Reply #2 on: February 16, 2020, 10:21:40 am »
Thank you. Will read in-depth later today albeit from skimming it, I am not 100% sure it covers my case.

Update:

After enabling (and then disabling) theming in project options I am getting duplicate errors (did not get any errors before) about mainicon...

When inspecting the Lazarus generated directory: x86_64-win64 ... It now contains both:

1)
originating from myapp.dpr:
  • whatever1.res
Code: Pascal  [Select]
  1. {$IFDEF myms_App_Whatever1}
  2. {$R ./resources/whatever1.res}
  3. {$ENDIF}
  4. {$IFDEF myms_App_Whatever2}
  5. {$R ./resources/whatever2.res}
  6. {$ENDIF}
  7.  

2)
and the following .res files generated by lazarus:
  • myapp.res
  • myapp.reslst

So... I will reread the link you posted. But under all circumstances, the problem appears clear. Lazarus enforces generating its own .res file
« Last Edit: February 16, 2020, 10:31:55 am by MISV »

MISV

  • Hero Member
  • *****
  • Posts: 683
Re: Lazarus Windows : Forcing Lazarus to use custom .res file
« Reply #3 on: February 17, 2020, 11:00:41 pm »
Even if I before compilation copy and rename

./resources/whatever1.res
to
myapp.res

Lazarus insist on re-creating it.

And that is the problem/bug? There will never be a way where I can supply my own .res file defining everything (icons, themes, scaling etc.) if Lazarus insist on overwriting it.

Is there a workaround for this? Maybe some compiler option where I can specify not to have compiler/lazarus create .res file?

trev

  • Hero Member
  • *****
  • Posts: 524
  • Former Delphi 1-7 and 10.2 User
Re: Lazarus Windows : Forcing Lazarus to use custom .res file
« Reply #4 on: February 18, 2020, 08:07:43 am »
Brute force :)  Edit the Lazarus source to stop it re-creating .res files if they exist.
o Lazarus v2.1.0 r62775, FPC v3.3.1 r44289, macOS 10.14.6 (with sup update), Xcode 10.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0 (Parallels VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

MISV

  • Hero Member
  • *****
  • Posts: 683
Re: Lazarus Windows : Forcing Lazarus to use custom .res file
« Reply #5 on: February 18, 2020, 11:31:57 am »
I guess one could create separate project files for all my apps and use Lazarus options...

But does this problem not constitute a problem for others as well in case you want to create a custom manifest?

i.e. there should be a way to avoid Lazarus re-creating .res files I think. Maybe only recreate if the relevant options (theme, icon etc.) are edited in Lazarus?


kupferstecher

  • Sr. Member
  • ****
  • Posts: 365
Re: Lazarus Windows : Forcing Lazarus to use custom .res file
« Reply #6 on: February 18, 2020, 11:49:10 am »
When sharing a project, you don't need the res-file, it's created by Lazarus using the project settings (lpi-file), so a second res-file maybe is a bad idea anyways.

I guess one could create separate project files for all my apps and use Lazarus options...
You could create/modify the lpi-file for each app version according your needs (like you do it with the .res) and compile the project via command line.
I never did that, others can help you better. You may search for 'lazbuild'.

MISV

  • Hero Member
  • *****
  • Posts: 683
Re: Lazarus Windows : Forcing Lazarus to use custom .res file
« Reply #7 on: February 19, 2020, 01:40:22 am »
(Thank you for help everyone)

I am considering submitting a feature request because it appears it is not possible to have a custom manifest file. (i.e. supply .res file oneself with a custom manifest + icons)

I think that ought'a be made possible :)