Reputation: 48
hello how can i change (delphi firemonkey mobile application) stylebook runtime
i will try load from ini or text file when formcreate or formshow
but cannot work stylename is string
i was try this code but code1 work but code 2 cannot work
if RadioButton1.IsChecked then Form1.StyleBook:=white else Form1.StyleBook:=black;
i need
form1.stylebook:= trim(Copy(Memo2.Lines.Strings[0],7,30)); {string ='black'}
but error code :[dcc32 Error] main.pas(226): E2010 Incompatible types: 'TStyleBook' and 'string'
Upvotes: 1
Views: 1809
Reputation: 2977
To clear up some confussion:
StyleBook property requires an object instance type of TStyleBook so your attempt to pass a string to that property will produce the Incompatible types error.
StyleName is the name by which a style or style subcomponent is known for. I'm not exactly sure why you mentioned the StyleName property as it doesn't seem to have anything to do with your question.
To return to your question, how to load a style into a TStyleBook at runtime and apply it to the Form?
var
aStyleBook : TStyleBook;
begin
// Create styleBook and assign the main form as its owner
aStyleBook := TStyleBook.Create(Self);
// Load style from file or Stream
aStyleBook.Resource.LoadFromFile('...');
// set the loaded style as active style
Self.StyleBook := aStyleBook;
end;
Upvotes: 4