简体   繁体   English

从BPL中的资源加载VCLSTYLE

[英]Loading a VCLSTYLE from a resource in a BPL

Using Embarcadero C++Builder XE7. 使用Embarcadero C ++ Builder XE7。

We have placed a few styles into a resource. 我们已经在资源中放置了一些样式。 The styles have been added using the "Project -> Resources and Images" dialog. 使用“项目->资源和图像”对话框添加了样式。 The resulting .rc file looks like this: 生成的.rc文件如下所示:

Auric VCLSTYLE "C:\\Program Files (x86)\\Embarcadero\\Studio\\15.0\\Redist\\styles\\vcl\\Auric.vsf"
Carbon VCLSTYLE "C:\\Program Files (x86)\\Embarcadero\\Studio\\15.0\\Redist\\styles\\vcl\\Carbon.vsf"

During build, I can see the resource is built and linked. 在构建期间,我可以看到资源已构建并链接。

I would like to now access this from my main application, which has linked to this lib, using TStyleManager::Styles . 我现在想使用TStyleManager::Styles从已链接到该lib的主应用程序访问此文件。 No matter if I include the RC directly, or put it in a BPL and load it with LoadPackage() , However, it only returns the Windows style, not the ones listed above. 无论我直接包含RC还是将其放入BPL并使用LoadPackage()加载它,但是,它仅返回Windows样式,而不返回上面列出的样式。 How do I get the main application to load these resources? 如何获得主应用程序来加载这些资源?

When adding the aforementioned RC file by hand to the library (or application directly), so that it could be compiled by the resource compiler into a RES file and linked into BPL (or into the application executable), I needed to add 当将上述RC文件手动添加到库(或直接应用程序)中,以便可以由资源编译器编译为RES文件并链接到BPL(或应用程序可执行文件)时,我需要添加

#include <Vcl.Themes.hpp>
#include <Vcl.Styles.hpp>

in the application. 在应用程序中。 Otherwise, even though the RC is linked correctly, the styles are not accessible at runtime. 否则,即使RC正确链接,也无法在运行时访问样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM