在Mac OS X上从资源加载样式 [英] Loading style from resource on Mac OS X
问题描述
在C ++ Builder XE6中使用Firemonkey(FMX),我试图在项目的cpp文件中加载样式。
Using Firemonkey (FMX) in C++ Builder XE6, I am attempting to load a style in my project's cpp file.
在
Application->Initialize ()
我有
Fmx::Types::TFmxObject *style;
style = TStyleStreaming::LoadFromResource((unsigned int)HInstance, L"MacJet", RT_RCDATA);
TStyleManager::SetStyle (style);
其中,名为MacJet的样式已在设计时作为资源加载到项目中。
where the style named MacJet has been loaded as a resource into the project at design time.
当我激活Win32作为目标平台时,它运行良好,并且样式在应用程序中正确显示。
When I activate Win32 as the target platform, this runs fine, and the style shows properly in the application.
何时我激活了Mac OS X,但是在style = ...行上出现错误,提示
When I activate Mac OS X, however, I get an error on the style = ... line, stating
异常类SIGSEGV(11)。
"Exception class SIGSEGV (11)."
当我删除上面的三行并在Mac上运行时,程序会加载。
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?
推荐答案
解决方法:不要使用资源并在加载样式之前应用程序初始化后,我在应用程序的主窗体中添加了一个TStyleBook,在设计时将样式添加到了样式书中,然后调用TStyleManager :: SetStyle()传入样式书的Style属性以在主窗体的Create事件上设置应用程序的样式。
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.
这篇关于在Mac OS X上从资源加载样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!