Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The SRP Button Control allows developers to set an icon for each button state, but the mechanism for doing so is not obvious when just looking at the property names. In understand how the icons are establish, we must first understand the concept of image frames.

Image Frames

Both the Icon and IconList properties allow you to establish a frame count. The frame count is used to determine how the loaded image file is divided into a list of smaller images, or frames. The easiest way to see this is by example. Here is a single image file, 288 pixels wide and 27 pixels tall.


Image file.pngImage RemovedImage Added


This image clearly has nine icons in it, but the SRP Button Control doesn't know that. So, we set the frame count to 9. In so doing, the SRP Button Control divides the width of the whole image by 9 and those are the frame. In this case, setting the frame count to 9 results in 9 32-pixel wide images.

The frame count is set within the Icon and IconList properties, usually as a field or subvalue. For example, to load our sample image, we use this code:

Code Block
Set_Property(@Window:".OLE_BUTTON", "OLE.Icon", "C:\myicons.bmp":@FM:9)

...

When we view the button, we see only the first of the nine icons on the button face:


Button Example 1.pngImage RemovedImage Added


Here's what happens when we load the sample image but forget to set the frame count to 9:

Button Example 2.pngImage RemovedImage Added


The entire 288 pixel wide image is centered on the button. Now the we understand how icons are divided, let's explore how the frames are used by the button.

...

The SRP Button Control has up to nine states, so you can supply up to nine frames in your image:


Button 9 Frames.pngImage RemovedImage Added


The table below shows which frame applies to each state:

...

In short, you may include as many or as few frames as you wish and the SRP Button Control is smart enough to adapt.

See Also

IconIconList