Using Styles Defined by Components in Design-Time Packages Installed in the IDE

From RAD Studio
Jump to: navigation, search

Go Up to Customizing FireMonkey Applications with Styles


Custom components defined in your FireMonkey unit can define new styles. You can register these custom components in the unit and build a package from this unit.

You can install in the IDE this design-time package registering these custom components. When you run the IDE loading a project that does not use any registered component from this package, the IDE, by default, uses smart (lazy) loading of components. Therefore, the custom components from this package are not loaded into the memory. As result, the styles defined by these components are not known to the IDE. Styles are referenced in style books explicitly using the StyleName strings. Therefore, usage of StyleName defined for the custom component does not enforce the IDE to load this custom component if it is not used in a loaded project. Opening such a project generates then an error like:

Error reading <StyleBook1.ResourcesBin>: Class <ComponentClass> not found. 
Ignore the error and continue?
NOTE: Ignoring the error may cause components to be deleted or property
values to be lost.   

If you ignore such error messages, the reported style is not known to the project. If you build such a project and run the obtained application, the application can generate a run-time error if it tries to access this style.

For these custom components you need to explicitly disable smart loading of a package in which these components are registered.

To disable smart loading of components registered in a package call

ForceDemandLoadState(dlDisable)

during the implementation of the Register procedure of a package if the loading state of that package needs to be set explicitly.

Smart (lazy) loading of design-time packages works in the following way. By default, the IDE uses smart loading of design-time packages installed in the IDE. When the IDE starts, the IDE does not immediately load all installed packages. Initially, only the installed packages components which are explicitly used in the project group are loaded by the IDE. Packages that are not loaded, can be automatically loaded on demand. For example, when the programmer drags a component from the Tool Palette into the Form Designer, then the package in which this component is registered is loaded into the IDE. Smart loading is used to decrease the IDE opening time and used memory.

See Also