Copyright © 1998-2015 MultiMedia Soft

How to speed up buttons rendering

Previous pageReturn to chapter overviewNext page

As you may suspect, the rendering of complex 3D buttons requires more CPU ticks than the rendering of default Windows flat square button. There can be a significant slowdown in performance when there are many buttons to be rendered on a form or dialog box. However, when an application renders a large number of consistently formatted buttons, there is a way to increase rendering performance. This is achieved through caching.

Beginning with Version 7 of the control, a new buttons caching system has been available to speed up the time required to load forms. This system is based on the assumption that if a button surface has already been created for a particular button it can be reused by other buttons having the same morphological characteristics.

As an example, consider the following two forms:

3dabm_i0000a2

3dabm_i0000a3

Both forms have the same number of buttons. On the first form, all of the buttons differ from each other. On the second form, all of the buttons are the same (except for their captions, which does not affect load time). In the caching system, the second form will load much more quickly because the first button can serve as a template for all of the buttons. Furthermore, even after Form2 is closed, the button will remain in cache so that if the form is opened again, the button will not need to be recalculated and may be used immediately.

In order for the caching system to work, buttons on a form must have the following morphological characteristics in common:

Size (intended as horizontal and vertical dimensions)
All of the settings available inside the Shape and Surface tabs of 3D Button Visual Editor
All of the settings available inside the Colors tab of 3D Button Visual Editor
All of the settings available inside the Texture tab of 3D Button Visual Editor
The Focus mode setting available inside the Others tab of 3D Button Visual Editor
The Anti-aliasing setting available inside the Others tab of 3D Button Visual Editor

As you can see, settings declared inside the Texts tab and inside the Graphics tab of 3D Button Visual Editor will not affect the caching system, so you will have enough ways to distinguish buttons from each other.

Obviously this section's goal is not to tell you how to design your application's user interface, but it gives you a means to speed up your user interface loading time.

Another issue that can slow down the rendering time is the modification of button's morphological characteristics on the container form loading routine (for example the Visual Basic 6 Form_Load subroutine): always try to setup the button's properties that influence a morphological characteristics at Design time only.

 

IMPORTANT NOTES:

Buttons with alpha channel transparency (set through the SurfaceTransparentFactor property or SetTotalTransparentFactor method) will not be stored in cache.
If controls are placed inside a form with a background picture, the caching system will not be effective: controls need to anti-alias their external border with the underlying portion of the picture so each control will have a different bitmap: if you need a fast rendering speed avoid the use of background pictures in your forms or, in alternative, set the UseAntialiasing property to FALSE and the SurfaceTransparentFactor property to 0.
If for any reason you should decide that you need more memory for your application, you could use the ClearButtonCache method in order to free all the memory dedicated to the cached buttons storage; note that the cache size starts growing only when the first button is created: no amount of memory is pre-allocated. At any time, you can know the amount of memory used by the caching system calling the GetButtonCacheSize method.
The caching system is enabled by default: if you need more memory for your application, you can disable the caching system through the EnableButtonCache method.