Recent

Author Topic: Incorrect color on Windows 10/11  (Read 2686 times)

C0m3b4ck

  • New Member
  • *
  • Posts: 30
  • Open-source programs for Windows 95-11 and Linux
    • Github
Incorrect color on Windows 10/11
« on: March 29, 2026, 07:47:00 am »
I compiled my program using FPC 3.0.0, x32 target. When I run my program on Windows 10 and 11, smaller forms without TPageControl and TTabSheets have the correct color (clBlue). However, my form using TPageControl and TTabSheets is set to white, screenshots below, with the area not included in TPageControl being blue.

What is the solution? I'm sure it involved setting parent color and gettting color after parent.

Thank you for your time!  :)
Github profile - https://github.com/C0m3b4ck | YouTube Channel - https://youtube.com/@PrinterFixer
Current Pascal project - https://github.com/C0m3b4ck/BookwormPascal - library book management app

Still making sure I support Win95 for its users out there...

dseligo

  • Hero Member
  • *****
  • Posts: 1686
Re: Incorrect color on Windows 10/11
« Reply #1 on: March 29, 2026, 03:07:23 pm »
However, my form using TPageControl and TTabSheets is set to white, screenshots below, with the area not included in TPageControl being blue.

Where is TPageControl in your screenshot? Can you post design-time screenshot of the form?

It would be better if you make small demo program which shows your problem and post compilable files here.

You can try something like this (I don't know if it works in Lazarus 3.0, I use 4.4):
Code: Pascal  [Select][+][-]
  1. uses UxTheme;
  2. ...
  3. procedure TYourForm.FormCreate(Sender: TObject);
  4. begin
  5.   SetWindowTheme(TPageControl(PageControl1).Handle, nil, '');
  6. end;

P.S.: This works only in Windows.

Zvoni

  • Hero Member
  • *****
  • Posts: 3398
Re: Incorrect color on Windows 10/11
« Reply #2 on: March 30, 2026, 08:44:09 am »
You can try something like this (I don't know if it works in Lazarus 3.0, I use 4.4):
He's using Lazarus 1.6.2
His FPC is 3.0.0
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12423
  • Debugger - SynEdit - and more
    • wiki
Re: Incorrect color on Windows 10/11
« Reply #3 on: March 30, 2026, 10:35:05 am »
It's probably either missing or out-of-date manifest.

No idea, if/where that can be changed in 3.0.
In current versions "project options" have settings on the "application" page: "use manifest / enable themes"

It may also be, that Lazarus/LCL 3.0 just doesn't support newer themes... (maybe something old is hardcoded somewhere)

Zvoni

  • Hero Member
  • *****
  • Posts: 3398
Re: Incorrect color on Windows 10/11
« Reply #4 on: March 30, 2026, 10:52:43 am »
It's probably either missing or out-of-date manifest.

No idea, if/where that can be changed in 3.0.
In current versions "project options" have settings on the "application" page: "use manifest / enable themes"

It may also be, that Lazarus/LCL 3.0 just doesn't support newer themes... (maybe something old is hardcoded somewhere)
OP is using Lazarus 1.6.2
His FPC is 3.0.0
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

C0m3b4ck

  • New Member
  • *
  • Posts: 30
  • Open-source programs for Windows 95-11 and Linux
    • Github
Re: Incorrect color on Windows 10/11
« Reply #5 on: March 30, 2026, 06:22:06 pm »
Yes, I am using Lazarus 1.6.2 with FPC 3.0.0 for backwards compatibility. While reading much deeper, I found this solution: https://lists.lazarus-ide.org/pipermail/lazarus/2016-October/229882.html

It involves disabling manifest like Martin_fr mentioned, because Windows DWM (in versions Vista+) forces white background when manifests are on. However, upon running the app on modern systems, it will have the Windows Classic (9x) theme. For me, that is not worth it just to keep background colors.

Since I am planning to ship a separate x32 and x64 build anyway, I will try to compile using FPC 3.2.2 with Lazarus 4. Will report on how it goes.
Github profile - https://github.com/C0m3b4ck | YouTube Channel - https://youtube.com/@PrinterFixer
Current Pascal project - https://github.com/C0m3b4ck/BookwormPascal - library book management app

Still making sure I support Win95 for its users out there...

C0m3b4ck

  • New Member
  • *
  • Posts: 30
  • Open-source programs for Windows 95-11 and Linux
    • Github
Re: Incorrect color on Windows 10/11
« Reply #6 on: March 31, 2026, 07:38:22 pm »
I initially feared that disabling Manifest would make my app have the Windows Classic theme - that was proven wrong. I recompiled my app on Windows 10 with disabled manifest, colors work perfectly! Thank you @Martin_fr and @dseligo for the help!  ;D
Github profile - https://github.com/C0m3b4ck | YouTube Channel - https://youtube.com/@PrinterFixer
Current Pascal project - https://github.com/C0m3b4ck/BookwormPascal - library book management app

Still making sure I support Win95 for its users out there...

 

TinyPortal © 2005-2018