2
votes

Using Firemonkey (FMX) in C++ Builder XE6, I am attempting to load a style in my project's cpp file.

Just before

Application->Initialize ()

I have

Fmx::Types::TFmxObject *style;
style = TStyleStreaming::LoadFromResource((unsigned int)HInstance, L"MacJet", RT_RCDATA);
TStyleManager::SetStyle (style);

where the style named MacJet has been loaded as a resource into the project at design time.

When I activate Win32 as the target platform, this runs fine, and the style shows properly in the application.

When I activate Mac OS X, however, I get an error on the style = ... line, stating

"Exception class SIGSEGV (11)."

When I remove the three lines above and run on Mac, the program loads up.

I'm new to cross-platform development, any ideas what is causing this error?

1
Why did you cast HInstance to unsigned int? Is it possible for you to debug the FMX code and step through the LoadFromResource function as it executes? - David Heffernan
I am casting from HInstance to unsigned int because of the code sample here docwiki.embarcadero.com/RADStudio/XE6/en/… , which does that when setting a style from a resource in the C++ sample. - Anthony Burg
When I debug, the error message occurs immediately after tracing into that line or trying to step over it. - Anthony Burg
Trying it without the unsigned int cast on the HInstance doesn't seem to change the error. - Anthony Burg
Did you build with debug DCUs? Still, why are you casting? It's is clearly wrong and will break in an x64 build. - David Heffernan

1 Answers

0
votes

Workaround solution: instead of using a resource and loading the style before the application initialized, I added a TStyleBook to the application's main form, added the style to the stylebook at design time, and then called TStyleManager::SetStyle () passing in the stylebook's Style property to set the application's style on the main form's Create event.