简体   繁体   中英

Loading a VCLSTYLE from a resource in a BPL

Using 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:

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 . 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. 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

#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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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