1

I'm trying to load a style resource using this code:

var
  Style: TFmxObject = nil;

begin
{$IFDEF IOS}
  Style := TStyleStreaming.LoadFromResource(HInstance, 'iphonestyle', RT_RCDATA); // access violation :(
{$ENDIF}
  if Assigned(Style) then
    TStyleManager.SetStyle(Style);
  Application.Initialize;
  Application.CreateForm(TfrmLogIn, frmLogIn);
  Application.Run;

end.

But I'm getting an access violation on LoadFromResource line. I've added the .style file to my project using Project\Resources and Images... menu item. Any ideas on what's causing AV?

iMan Biglari
  • 4,674
  • 1
  • 38
  • 83
  • 2
    That looks like a firemonkey issue. Take a look at this topic for the additional info: http://stackoverflow.com/questions/23741597/loading-style-from-resource-on-mac-os-x – Ari0nhh Jan 09 '15 at 10:41
  • @Ari0nhh Well, I am unable to use StyleBooks as suggested in that question. Take a look @ http://stackoverflow.com/questions/27840341/fmx-style-issue-with-modal-forms?noredirect=1#comment44086413_27840341 – iMan Biglari Jan 10 '15 at 06:47
  • That's as maybe, but it's the exact same question – David Heffernan Jan 11 '15 at 09:18
  • Why do you want to load it from recourse rather then put it in a stylebook component and then load it? Also have you added the file for all configurations(Debug/Release) in the project deployment? – Remi Mar 03 '15 at 09:17
  • @Remi Because I don't want to link every form's `StyleBook` property. – iMan Biglari Mar 03 '15 at 11:32
  • @iManBiglari try to add the file using the deployment and add it for all configurations. Then load it using TPath.GetDocumentsPath +filename – Remi Mar 04 '15 at 09:56
  • don't forget to have the permissions read and write from storage – Remi Mar 04 '15 at 09:57
  • @Remi I get this AV on Windows :(. Haven't tried other platforms yet – iMan Biglari Mar 04 '15 at 13:32
  • @iManBiglari you can't load iOS styles on any other platform than on iOS it self. – Remi Mar 04 '15 at 13:48
  • I'm having a similar issue, and it seems that on iOS (at least), style streams are read differently than on Win32. I haven't narrowed it down as to why, just yet. The result is however that if an image resource referred to by the styles appears *after* the styles in question, it blows up. Moving the image resource to the beginning of the style file resolves the issue. – Dave Nottage Jul 05 '15 at 22:20

0 Answers0