The UIS2 Tutorial - Buttons

There are 2 types of buttons that you need to support in Windows; those in the frame (e.g. Maximize, Close etc), and the buttons used within applications including radio buttons and check buttons.

While we were dealing with the frame of the window in the [Personality] section I alluded to the fact we would come back to the buttons of the frame so here we are. In fact, ‘buttons’ is a bit of a misnomer as all graphics in the frame with ‘actions’ attributed to them are referred to as ‘buttons’. The way these ‘buttons’ are defined is that some commands are placed within the [Personality] section, and then each button has a section of it’s own like [Button0].

We will start by looking at the commands that need placing within the [Personality] section.

ButtonCount=7

Here you specify the number buttons in the frame, each of which has its own section; in this case from [Button0] to [Button6].

RightClickAction=4

Previously it was mentioned how WindowBlinds can add functionality beyond standard Windows functionality. You can specify here a command that can be performed when the user right clicks on the title bar. The list of options is as follows:

·         0 = Close window
·         1 = Maximize/Restore window
·         2 = Minimize window
·         3 = Help button
·         4 = Rollup/Unroll window
·         6 = Force window to be 'always on top'
·         7 = Attach window to the desktop (Always on bottom)
·         8 = Keep window visible always - LiteStep only
·         9 = Prevent window from being sized or moved
·         10 = Start screensaver
·         11 = Show system icon default window menu
·         21 = Send to bottom of z-order
·         24 = Minimize to Sys Tray (Windows2000 only - Unsupported Experimental Code)
·         25 = Make window transparent (Windows 2000 only - Unsupported Experimental Code)
·         -2 = Disable Action (Windows 2000 only - Unsupported Experimental Code)

RollupSize=33

When you specify that any of the buttons has ‘rollup’ functionality you must specify the size to which the window resizes. This is the height in pixels that the window will be after being rolled up.

TripleImages=1

This command is used to specify whether in your buttons use a source graphic that contains images just for the active window (0), or whether images are included for inactive windows as well (1).

MouseOver=1

This determines that the images used for buttons also contain an image that is shown when the mouse cursor is over the button. You will study the structure of the source graphics for buttons in the later sections.

We will now actually go through the buttons and examine the code.

Action Buttons

Each button requires a section [ButtonX] where X is the number of the button. Below is the code for 4 buttons which have a similar structure. After the code we will go through each common line to examine its purpose

[Button1]
XCoord=22
YCoord=6
Align=1
Action=0
ButtonImage=Aquarium\exit.bmp
Visibility=0
InSound=Aquarium\close.wav

[Button2]
XCoord=40
YCoord=6
Align=1
Action=22
Visibility=20
ButtonImage=Aquarium\max.bmp
InSound=Aquarium\Restore.wav

[Button3]
XCoord=58
YCoord=6
Align=1
Action=23
Visibility=22
ButtonImage=Aquarium\min.bmp
InSound=Aquarium\Minimize.wav

[Button5]
XCoord=40
YCoord=6
Align=1
Action=22
Visibility=21
ButtonImage=Aquarium\max.bmp
InSound=Aquarium\Restore.wav
Alpha=180

[Button6]
XCoord=58
YCoord=6
Align=1
Action=23
Visibility=23
ButtonImage=Aquarium\min.bmp
InSound=Aquarium\Minimize.wav
Alpha=180

That is the code, now for the breakdown:

Align=1

This specifies an alignment for your button and is the first sign that WindowBlinds is much more flexible that normal windows. The value you give this parameter is taken from the list below.

·         0 = relative to top left of window
·         1 = relative to the top right of window
·         2 = relative to bottom left of window
·         3 = relative to bottom right of window
·         4 = middle of top edge. Does not permit the button to be pressed in.
·         5 = middle of bottom edge. Does not permit the button to be pressed in.
·         6 = middle of left edge. Does not permit the button to be pressed in.
·         7 = middle of right edge. Does not permit the button to be pressed in.
·         8 = left of caption text.
·         9 = right of caption text.
·         10 = align top border
·         11 = align bottom border
·         12 = align left border
·        13 = align right border

XCoord=22

To fine tune the setting you gave in the Align parameter you can horizontally offset the button from this position. Where the button is placed in a corner, a positive value offsets the button towards the centre of the window, and a negative value away from the centre. In this example, the button is offset from the top right corner of the window by 22 pixels towards the centre of the top frame.

YCoord=6

This is the complimentary parameter to XCoord and offsets vertically relative to the position set by Align.

Action=0

This is the one you’ve been waiting for, defining what the button actually does. The value of this parameter is selected from the list below. This button has a value of 0 indicating that it performs the ‘Close window’ function.

·         -6 = Do nothing. Just show an image. Passes mouse messages to the titlebar.
·         -5 = dll button. Non clickable. Treated as an integral part of the titlebar.
·         -4 = dll button. Click handled by plugin, drawing done by WindowBlinds.
·         -3 = dll button. For use with external plugin
·         -2 = Do nothing. Just show an image. Does intercept mouse messages.
·         -1 = Do nothing. Just show an image. Does not intercept mouse messages.
·         0 = Close window
·         1 = Maximize window - Shows Disabled State
·         2 = Minimize window - Shows Disabled State
·         3 = Help button
·         4 = Rollup / Unroll window
·         5 = Execute command associated to this button.
·         6 = Force Window to be Always on Top
·         7 = Attach window to the desktop (Always on bottom)
·         8 = Keep window visible always - LiteStep only
·         9 = Prevent window from being sized or moved
·         10 = Start screensaver
·         11 = System Icon (default icon as shown in normal window)
·         12 = Show System Menu (functions as System Icon w/ specific image)
·         13 = Size window from the top
·         14 = Size window from the bottom
·         15 = Size window from the left
·         16 = Size window from the right
·         17 = Size window from top left
·         18 = Size window from the top right
·         19 = Size window from the bottom left
·         20 = Size window from the bottom right
·         21 = Send window to bottom of z-order
·         22 = Maximize Button - with MouseOver
·         23 = Minimize Button - with MouseOver
·         24 = Minimize to Systray (Windows2000 only - Unsupported Experimental Code)
·         25 = Make window transparent (Windows 2000 only - Unsupported Experimental Code)
·         40 = 'Link-To' Toggle - for use with visibility='Link-To' *Note: This button should not have visibility='Link-To'}

ButtonImage=Aquarium\exit.bmp

This is the source image for the button. The image again contains all of the required states in a single image. The first 3 are for the normal window, and the last optional 3 are for the inactive windows.

1.      Normal
2.      Pressed
3.      Disabled / Mouse over
4.      Inactive Normal (optional)
5.      Pressed (optional)
6.      Disabled / Mouse over (optional)

Visibility=0

This command determines under which circumstances a button is visible. The code can be chosen from those in the list below. If you require, you can use up to 10 codes at once by separating them with AND, for example 5 AND 9 AND 24.

·         0 = Always show button
·         1 = Show if window is active
·         2 = Show if window is inactive
·         3 = Show if window is maximized
·         4 = Show if window is NOT maximized
·         5 = Show if window is rolled up
·         6 = Show if window is NOT rolled up
·         7 = Show if window has 'Always on top' set
·         8 = Show if window is NOT set as 'Always on top'
·         9 = Show if attached to desktop
·         10 = Show if NOT attached to desktop
·         11 = Show if 'Keep this window visible always'
·         12 = Show if NOT 'Keep this window visible always'
·         13 = Show if window has help button (WS_EX_CONTEXTHELP)
·         14 = Show if window does NOT have help button
·         15 = Show if window does NOT have max or min button and is NOT maximized
·         16 = Hide button if a maximize button exists or a minimize button exists
·         17 = Show if window does NOT have either minimize or maximize button
·         18 = Show if window is a MDI child
·         19 = Show if window is NOT a MDI child
·         20 = Show if window has a maximize button
·         21 = Show if window does NOT have a maximize button
·         22 = Show if window has a minimize button
·         23 = Show if window does NOT have a minimize button
·         24 = Show if window is sizable
·         25 = Show if window is NOT sizable
·         26 = Show if either a maximize or minimize button exists
·         27 = Show if window has a default icon
·         28 = Show if window does NOT have a default icon
·        
29 = Show if window text exist
·         30 = Show if window text DOES NOT exist
·         31 = Show if mouse is over the button specified in the LinkedTo line
·         32 = Show if button specified in the Link-To line is pressed in
·         33 = Show if button specified in the Link-To line is pressed in or ‘mouse over’
·         40 = Show if 'Link-To' button is toggled on {requires a button to have the 'Link-To' Toggle button action code}
·         41 = Show if 'Exclusive Link-To' button is toggled on {requires a button to have the 'Exclusive Link-To' Toggle button action code}
·         50 = Show if WindowBlinds is in Advanced mode (default) (Advanced skins only)
·         51 = Show if WindowBlinds is in Simple mode (Advanced skins only)
·         52 = Show if window is a Tool Window (Basic skins only)
·         53 = Show if window is not a Tool Window (Basic skins only)
·         54 = Show when window is enabled
·         55 = Show when window is disabled

InSound=Aquarium\close.wav

WindowBlinds allows you to allocate sound effects to actions. The InSound parameter allows you to specify a sound file that will be played which the button is clicked. In fact the InSound file plays when the mouse button is pressed in, and you can optionally specify an additional OutSound parameter to play a sound when the mouse button is released. All you need to do is specify a WAV file path relative to the WindowBlinds directory.

In order to use sounds in WindowBlinds you need to add an additional line to the [Personality] section of the skin. The line is SoundEnabled=1.

System & Plugin Buttons

Buttons don’t have to contain graphics and perform traditional maximize / minimize type functions. There are two buttons in this skin which do other things. The first is likely to be a button that you want in most skins that you create, as it displays the program icon which Windows normally displays in the top left corner. All you need to specify are it’s location via the Align, XCoord and YCoord parameters.

The final parameter is the Action parameter which we also examined earlier, using the value of 11 which the list above defines as ‘System Icon (default icon as shown in normal window)’.

[Button4]
XCoord=7
YCoord=5
Align=0
Action=11

Earlier, while discussing the animated frame I indicated that the animation would not work at that stage. The reason was the lack of the plugin that allows animation. The way to implement the plugin is via a button. Below is the code for the button containing the animation plugin ([Button0]).

[Button0]
XCoord=0
YCoord=0
Align=0
Action=-3
Width=0
Height=0
DllName=anim.dll

The first 4 parameters will now be familiar to you. The Width and Height parameters are optional parameters that indicate the width and height of the button (surprisingly!) and are set to 0 just to ensure the button is not visible.

The final parameter specifies the plugin to be used, but entering a file path relative to the WindowBlinds directory. The anim.dll file is the plugin that enables the animation on the window frame. Other plugins exist for such things as a clock and scrolling text.

MDI Buttons

It’s already been shown that WindowBlinds can skin the background of MDI windows, but these windows have their own buttons and WindowBlinds can skin those too.

As you can see the code is very simple, all you have to do is specify the image to be used and whether the image contains images for the Mouse Over state.

The states are as follows:

1.      Minimize button enabled
2.      Minimize button presses
3.      Minimize button disabled
4.      Minimize button mouse over
5.      Maximize button enabled
6.      Maximize button presses
7.      Maximize button disabled
8.      Maximize button mouse over
9.      Close button enabled
10.  Close button presses
11.  Close button disabled
12.  Close button mouse over

[MdiControls]
Image=Aquarium\button-mdi.bmp
MouseOver=1

Other Button Stuff

OK, so that covers the buttons in the frame, but there are other buttons that you need to deal with. This code gets its own section in the UIS file – the [Buttons] section. Here we will go through this section line by line.

[Buttons]
CheckButton=Aquarium\checkbox.bmp

Here you specify your source graphic for check buttons within your skin. Again the graphic contains multiple states. The image structure is made up as follows:

1.      Not Selected
2.      Selected
3.      Not Selected (Disabled)
4.      Selected (Disabled)

RadioButton=Aquarium\radio.bmp

Here you specify your source graphic for radio buttons within your skin. Again the graphic contains multiple states. The image structure is made up as follows:

1.      Not Selected
2.      Selected
3.      Not Selected (Disabled)
4.      Selected (Disabled)

 

Bitmap=Aquarium\button.bmp

This is where you specify the graphic to be used for command buttons in Windows. This doesn’t skin the Taskbar buttons which these are dealt with elsewhere, but all the buttons within application. The image structure is made up as follows:

1.      Normal
2.      Pressed
3.      Disabled
4.      Focus
5.      Default

The actual image has twice as many states because the MouseOver parameter has a value of 1 which means that states 6 to 10 replicate states 1 to 5 when the mouse cursor is over the button.

MouseOver=1

WindowBlinds can use a different image when the mouse cursor is over a button. As stated above this skin uses this and therefore this parameter has a value of 1.

TopHeight=5
BottomHeight=5
LeftWidth=5
RightWidth=5

These 4 parameters allow you, as you have done previously, to exclude the perimeters of the image from being stretched when a button is sized.

Trans=1

As per previous examples, you can specify the Trans parameter to specify whether ‘magic pink’ is used to define areas of transparency in the image. A value of ‘1’ shows that it is used.

Alpha=254

In addition to the ‘magic pink’ which is activated by the above statement, you can define the degree to which the button is transparent, and the window is visible through it. This is done via the Alpha parameter, which can range from 0 to 254. Where the value is 0, the [MENUITEM] image is totally transparent and the [MENUBACKGROUND] image is totally visible. At the other extreme as in this case the opposite applies.

Animated Buttons

Again, WindowBlinds is not content with standard Windows functionality and so you can use animation on your button. You specify the number of frames in the graphic, the gap between frames of the animation, and then which frames are animated in different circumstances. 

FrameCount=10

This parameter allows you to specify how many frames are in the source image.

AnimTimerRate=250

This specifies the time in milliseconds between frames in the animation used.

MouseEnterStartFrame=4

This is the first frame that is displayed when the mouse cursor enters the button area. The MouseOver animation will then start. The frame count starts at 0 so this is actually the fifth image.

MouseLeaveMode=1

This defines how WindowBlinds should deal with the animation when the mouse moves away from the button. You have two options:

0.      Stop animating immediately
1.      Finish the complete animation cycle

MouseOverStartFrame=5

This is the first frame that is used in the animation when the mouse moves over the button. The frame count starts at 0 so this is actually the sixth image.

MouseOverStopFrame=9

This is the last frame that is used in the animation when the mouse moves over the button. The frame count starts at 0 so this is actually the tenth image.

NormalFont=0
PressedFont=0
DisabledFont=0
FocusFont=2
DefaultFont=2
MouseOverFont=2

Text is typically displayed on command buttons, and WindowBlinds allows you to specify a different font style depending on the button state. These commands specify the fonts and the font code relating to this is expanded later.

Now you should know everything that you need to create your own buttons.

< Menus

(c) 2002 Stardock.net