# Rebar

Rebar control act as container for child windows. An application assigns child windows, which are often other controls, to a rebar control band. Rebar controls contain one or more bands, and each band can have any combination of a gripper bar, a bitmap, a text label, and a child window. However, bands cannot contain more than one child window. As you dynamically reposition a rebar control band, the rebar control manages the size and position of the child window assigned to that band.

Summary

Rebar | Rebar control act as container for child windows.
Add | Add a rebar to the GUI.
Count | Retrieves the number of bands in a rebar control.
DeleteBand | Deletes a band from a rebar control.
GetBand | Get band information.
GetLayout | Get layout of bands in rebar.
GetRect | Get band rectangle.
Height | Returns the height of the rebar control.
Id2Index | Returns 1 based position of the band with given id.
Insert | Inserts a new band in a rebar control.
Lock | Locks or unlcoks the rebar (sets or removes “nogripper” style for all bands in rebar)
MoveBand | Moves a band from one index to another.
SetBand | Sets characteristics of an existing band in a rebar control.
SetBandState | Minimize or maximize the band.
SetBandWidth | Sets the width for a band.
SetBandStyle | Sets the style for a band.
SetLayout | Set layout of bands in rebar.
SizeToRect |
ShowBand | Shows or hides the band.
Examples |
About |

### Add

> Rebar_Add( | hGui, |  |
> | Style | = | "",
> | hIL | = | "",
> | Pos | = | "",
> | Handler | = | "" | )

Add a rebar to the GUI.

#### Parameters

hGui | Handle of the GUI.
Style | White space separated list of styles. See bellow for details. By default “VARHEIGHT DBLCLKTOGGLE”. Integer styles are allowed.
hIL | Handle of the image list associated with the control. Optional.
Pos | Position of the rebar in usual AHK style. Optional.
Handler | Notification handler.

#### Styles

autosize | The rebar control will automatically change the layout of the bands when the size or position of the control changes.
bandborders | The rebar control displays narrow lines to separate adjacent bands.
dblclktoggle | The rebar band will toggle its maximized or minimized state when the user double-clicks the band. Without this style, the maximized or minimized state is toggled when the user single-clicks on the band.
fixedorder | The rebar control always displays bands in the same order. You can move bands to different rows, but the band order is static.
varheight | The rebar control displays bands at the minimum required height, when possible. Without this style, the rebar control displays all bands at the same height, using the height of the tallest visible band to determine the height of other bands.
verticalgripper | The size grip will be displayed vertically instead of horizontally in a vertical rebar control.
vertical | Causes the control to be displayed vertically.

#### Handler

>     Handler(hCtrl, Event)

Event | C (Chevron click) L (Layout change) H (Height change).

#### Returns

Handle to the newly created control or 0 if function failes. Error message is returned on invalid usage.

### Count

> Rebar_Count( | hRebar | )

Retrieves the number of bands in a rebar control.

### DeleteBand

> Rebar_DeleteBand( | hRebar,
> | WhichBand | )

Deletes a band from a rebar control.

#### Parameters

WhichBand | Band position or ID. Leave blank to get dimensions of the rebar control itself.

#### Returns

Nonzero if successful, or zero otherwise.

### GetBand

> Rebar_GetBand( |  | hRebar, |  |
> |  | WhichBand, |  |
> |  | pQ | = | "",
> | ByRef | o1 | = | "",
> | ByRef | o2 | = | "",
> | ByRef | o3 | = | "",
> | ByRef | o4 | = | "",
> | ByRef | o5 | = | "",
> | ByRef | o6 | = | "",
> | ByRef | o7 | = | "" | )

Get band information.

#### Parameters

WhichBand | Band position or ID.
pQ | Query parameter: S (Style), L (Length), C (Color), I (Icon index), T (Text), N (identificatioN), B (Bitmap handle).
o1..o7 | Reference to output variables.

#### Returns

o1

### GetLayout

> Rebar_GetLayout( | hRebar | )

Get layout of bands in rebar. Layout is single line string containing information about position of bars in the rebar control. Return value of this function is fed into SetLayout later, to restore layout.

### GetRect

> Rebar_GetRect( |  | hRebar, |  |
> |  | WhichBand | = | "",
> |  | pQ | = | "",
> | ByRef | o1 | = | "",
> | ByRef | o2 | = | "",
> | ByRef | o3 | = | "",
> | ByRef | o4 | = | "" | )

Get band rectangle.

#### Parameters

WhichBand | Band position or ID. Leave blank to get dimensions of the rebar control itself.
pQ | Query parameter: set x,y,w,h to return appropriate value, or leave blank to return all in single line.
o1 .. o4 | Output variables.

#### Returns

String with 4 values separated by space or requested information.

### Height

> Rebar_Height( | hRebar | )

Returns the height of the rebar control.

### Id2Index

Returns 1 based position of the band with given id.

#### Parameters

Id | ID of the band.

### Insert

> Rebar_Insert( | hRebar, |  |
> | hCtrl, |  |
> | o1 | = | "",
> | o2 | = | "",
> | o3 | = | "",
> | o4 | = | "",
> | o5 | = | "",
> | o6 | = | "",
> | o7 | = | "",
> | o8 | = | "",
> | o9 | = | "" | )

Inserts a new band in a rebar control.

#### Parameters

hCtrl | Control to be hosted by the band.
o1 .. o8 | Named parameters. See below.

#### Named parameters

S | Band styles separated by white space. By default “gripperalways”. See bellow.
L | Length of the band. By default, width of the child control is used + 10px
mW | Minimum width of the child control.
mH | Minimum height of the child control. By default the height of the child control.
I | Header icon index.
T | Header text.
C | Background and foreground color separated by space.
BG | Background bitmap.
P | 1-based position of the band. Set to 0 add the band to the end (default).

#### Band styles

break | The band is on a new line.
childedge | The band has an edge at the top and bottom of the child window.
fixedbmp | The background bitmap does not move when the band is resized.
fixedsize | The band can’t be sized. With this style, the sizing grip is not displayed on the band.
gripperalways | The band will always have a sizing grip, even if it is the only band in the rebar.
hidden | The band will not be visible. Don’t use this flag in Insert function. Instead, insert the band without this flag, then use SetBand to hide it. To restore it afterwards, use SetBand with “S show” parameter.
nogripper | The band will never have a sizing grip, even if there is more than one band in the rebar.
usechevron | Show a chevron button if the band is smaller than ideal.
novert | Don’t show when vertical.
hidetitle | Keep band title hidden.
* | Default styles for the band. For instance “* break” will set band style to default plus “break” style.

#### Returns

ID of the newly created band or 0 if it fails.

#### Remarks

For some reason, using the Gui, Font to change font size before adding ComboBox child to the band will make it buggy in a sense that ComboBox list will not be able to show (although you can still select items using arrows).

### Lock

> Rebar_Lock( | hRebar, |  |
> | Lock | = | "" | )

Locks or unlcoks the rebar (sets or removes “nogripper” style for all bands in rebar)

#### Parameters

Lock | Leave empty to lock, set to “-” to unlock, set to “~” to toggle.

### MoveBand

> Rebar_MoveBand( | hRebar, |  |
> | From, |  |
> | To | = | 1 | )

Moves a band from one index to another.

#### Parameters

From | 1-based index of the band to be moved.
To | 1-based index of the new band position. By default 1 (i.e. move to top).

#### Returns

TRUE if successful, or FALSE otherwise.

### SetBand

> Rebar_SetBand( | hRebar, |  |
> | WhichBand, |  |
> | o1 | = | "",
> | o2 | = | "",
> | o3 | = | "",
> | o4 | = | "",
> | o5 | = | "",
> | o6 | = | "",
> | o7 | = | "",
> | o8 | = | "",
> | o9 | = | "" | )

Sets characteristics of an existing band in a rebar control.

#### Parameters

WhichBand | Band position or ID that is about to be changed.
o1 .. o9 | Named parameters. Any named parameter that can be specified in Add function can be used here.

#### Returns

TRUE if successful, FALSE otherwise.

### SetBandState

> Rebar_SetBandState( | hRebar,
> | WhichBand,
> | State | )

Minimize or maximize the band.

#### Parameters

WhichBand | Band position or ID. Leave blank to get dimensions of the rebar control itself.
State | Set “-” to minimize, “+” to maximize to full width, “*” to maximize to ideal width (this is the width of the control when it is added to the band).

### SetBandWidth

> Rebar_SetBandWidth( | hRebar,
> | WhichBand,
> | Width | )

Sets the width for a band.

#### Parameters

WhichBand | Band position or ID.
Width | Width.

#### Returns

TRUE if the value was set and FALSE otherwise.

### SetBandStyle

> Rebar_SetBandStyle( | hRebar,
> | WhichBand,
> | Style | )

Sets the style for a band.

#### Parameters

WhichBand | Band position or ID.
Style | List of styles to add/remove for the band. Use - prefix to remove the style.

#### Returns

TRUE if successful, or FALSE otherwise.

#### Remarks

If you want to to replace band styles completely use SetBand function with S parameter. This function toggles desired styles.

### SetLayout

> Rebar_SetLayout( | hRebar,
> | Layout | )

Set layout of bands in rebar.

#### Parameters

Layout | String with information about position of bands in rebar control. Use GetLayout function to get this string. Layout syntax is:

>     id1 len1 break1|id2 len2 break2|....|idN lenN breakN

### SizeToRect

> Rebar_SizeToRect( |  | hRebar, |  |
> | ByRef | RECT | = | "~`a " | )

#### Parameters

RECT | Reference to rectangle structure. If omited, parents rectangle will be used (GetClientRect).

#### Remarks

The rebar bands will be arranged and wrapped as necessary to fit the rectangle. Bands that have the VARIABLEHEIGHT style will be resized as evenly as possible to fit the rectangle. The height of a horizontal rebar or the width of a vertical rebar may change, depending on the new layout.

### ShowBand

> Rebar_ShowBand( | hRebar, |  |
> | WhichBand, |  |
> | bShow | = | true | )

Shows or hides the band.

#### Parameters

WhichBand | Band position or ID. Leave blank to get dimensions of the rebar control itself.
bShow | True to show the band (default), FALSE to hide it.

#### Returns

TRUE if successful, or FALSE otherwise.

#### Remarks

This function can also be used to resize the band to mach the parents size. Put call to this function inside GuiSize routine. Update to first band will reposition all bands to match the Gui size. return

### Examples

>         Gui, +LastFound +Resize
>         hGui := WinExist()
>         Gui, Show, w400 h140 hide           ;set window size, mandatory

>       ;create edit
>         Gui, Add, Edit, HWNDhEdit w100 h100

>       ;create combo
>         Gui, Add, ComboBox, HWNDhCombo w80, item 1 |item 2|item 3

>       ;create rebar
>         hRebar := Rebar_Add(hGui)
>         ReBar_Insert(hRebar, hEdit, "mw 100", "L 400", "T Log ")    ;Insert edit band, set lenght of the band to 400
>                                                                     ; minimum width of edit to 100, set text to "Log "
>         ReBar_Insert(hRebar, hCombo, "L 300", "P 1")                ;Insert combo band at the top, set length of the band to 300

>         Gui, Show
>     return

### About

- Ver 2.02 by majkinetor.
- MSDN Reference: http://msdn.microsoft.com/en-us/library/bb774375(VS.85).aspx.
- Licenced under GNU GPL http://creativecommons.org/licenses/GPL/2.0/.

> Rebar_Add( | hGui, |  |
> | Style | = | "",
> | hIL | = | "",
> | Pos | = | "",
> | Handler | = | "" | )

Add a rebar to the GUI.

> Rebar_Count( | hRebar | )

Retrieves the number of bands in a rebar control.

> Rebar_DeleteBand( | hRebar,
> | WhichBand | )

Deletes a band from a rebar control.

> Rebar_GetBand( |  | hRebar, |  |
> |  | WhichBand, |  |
> |  | pQ | = | "",
> | ByRef | o1 | = | "",
> | ByRef | o2 | = | "",
> | ByRef | o3 | = | "",
> | ByRef | o4 | = | "",
> | ByRef | o5 | = | "",
> | ByRef | o6 | = | "",
> | ByRef | o7 | = | "" | )

Get band information.

> Rebar_GetLayout( | hRebar | )

Get layout of bands in rebar.

> Rebar_GetRect( |  | hRebar, |  |
> |  | WhichBand | = | "",
> |  | pQ | = | "",
> | ByRef | o1 | = | "",
> | ByRef | o2 | = | "",
> | ByRef | o3 | = | "",
> | ByRef | o4 | = | "" | )

Get band rectangle.

> Rebar_Height( | hRebar | )

Returns the height of the rebar control.

> Rebar_Insert( | hRebar, |  |
> | hCtrl, |  |
> | o1 | = | "",
> | o2 | = | "",
> | o3 | = | "",
> | o4 | = | "",
> | o5 | = | "",
> | o6 | = | "",
> | o7 | = | "",
> | o8 | = | "",
> | o9 | = | "" | )

Inserts a new band in a rebar control.

> Rebar_Lock( | hRebar, |  |
> | Lock | = | "" | )

Locks or unlcoks the rebar (sets or removes “nogripper” style for all bands in rebar)

> Rebar_MoveBand( | hRebar, |  |
> | From, |  |
> | To | = | 1 | )

Moves a band from one index to another.

> Rebar_SetBand( | hRebar, |  |
> | WhichBand, |  |
> | o1 | = | "",
> | o2 | = | "",
> | o3 | = | "",
> | o4 | = | "",
> | o5 | = | "",
> | o6 | = | "",
> | o7 | = | "",
> | o8 | = | "",
> | o9 | = | "" | )

Sets characteristics of an existing band in a rebar control.

> Rebar_SetBandState( | hRebar,
> | WhichBand,
> | State | )

Minimize or maximize the band.

> Rebar_SetBandWidth( | hRebar,
> | WhichBand,
> | Width | )

Sets the width for a band.

> Rebar_SetBandStyle( | hRebar,
> | WhichBand,
> | Style | )

Sets the style for a band.

> Rebar_SetLayout( | hRebar,
> | Layout | )

Set layout of bands in rebar.

> Rebar_SizeToRect( |  | hRebar, |  |
> | ByRef | RECT | = | "~`a " | )

> Rebar_ShowBand( | hRebar, |  |
> | WhichBand, |  |
> | bShow | = | true | )

Shows or hides the band.
Close