Recent

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

MISV

  • Hero Member
  • *****
  • Posts: 783
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user

MISV

  • Hero Member
  • *****
  • Posts: 783
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: 783
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 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.

MISV

  • Hero Member
  • *****
  • Posts: 783
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

  • Hero Member
  • *****
  • Posts: 583
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: 783
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 :)


 

TinyPortal © 2005-2018