Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: change Tstylebook properties at runtime


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 4 - Last Post: Jul 4, 2017 2:25 AM Last Post By: Jordi Montoya
Jordi Montoya

Posts: 6
Registered: 4/21/05
change Tstylebook properties at runtime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 3, 2017 4:44 AM
Hello, I want to change forms colors at runtime using TStylebook.

This code changes form background color, but only in x32. In x64 and Osx the new color is not applied.

procedure TForm1.FormCreate(Sender: TObject);
var r,g,b:Byte;
re:TFMXObject;
begin
r:=255;
g:=0;
b:=0;
re:=stylebook1.Style.FindStyleResource('backgroundstyle');
TRectangle(re).Fill.Color:=system.UIConsts.makecolor(r,g,b,$FF);
end;

I used similar code in XE4 and now when I've updated to Tokyo I've found this error.

Anyone has a solution?
Francesco Marano

Posts: 59
Registered: 11/18/02
Re: change Tstylebook properties at runtime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 3, 2017 6:31 AM   in response to: Jordi Montoya in response to: Jordi Montoya
Hello,

This works for Win64. Not tested for OSX.

Self.StyleBook := nil;
 
 re := stylebook1.Style.FindStyleResource('backgroundstyle');
TRectangle(re).Fill.Color := TAlphaColors.Red;
 
Self.StyleBook := stylebook1;


Regards,
Francesco
Jordi Montoya

Posts: 6
Registered: 4/21/05
Re: change Tstylebook properties at runtime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 3, 2017 7:03 AM   in response to: Francesco Marano in response to: Francesco Marano
Hello, I'v tried this code but it doesn't solve the problem in x64. Do you have all the updates available applied to Tokyo?

Thank you anyway!

Francesco Marano wrote:
Hello,

This works for Win64. Not tested for OSX.

Self.StyleBook := nil;
 
 re := stylebook1.Style.FindStyleResource('backgroundstyle');
TRectangle(re).Fill.Color := TAlphaColors.Red;
 
Self.StyleBook := stylebook1;


Regards,
Francesco
Francesco Marano

Posts: 59
Registered: 11/18/02
Re: change Tstylebook properties at runtime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 3, 2017 7:10 AM   in response to: Jordi Montoya in response to: Jordi Montoya
Hello,

Yes, I tested using Tokio + patch,
using ..\styles\Fmx\Dark.style and \Win10ModernPurple.style

I put the StyleBook component directly in TForm1.

Regards,
Francesco
Jordi Montoya

Posts: 6
Registered: 4/21/05
Re: change Tstylebook properties at runtime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 4, 2017 2:25 AM   in response to: Francesco Marano in response to: Francesco Marano
Hello, finally I've found that I if load the style file from filename property of stylebook it works in x64 and Osx. There is no need to set Self.StyleBook := nil / Self.StyleBook := Self.StyleBook.
But If the style is loaded doing dblclick over stylebook and loading the file from there, then it doesn't work.

Best regards
Jordi

Francesco Marano wrote:
Hello,

Yes, I tested using Tokio + patch,
using ..\styles\Fmx\Dark.style and \Win10ModernPurple.style

I put the StyleBook component directly in TForm1.

Regards,
Francesco
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02