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.

(See rebar.png)

Summary
RebarRebar control act as container for child windows.
AddAdd a rebar to the GUI.
CountRetrieves the number of bands in a rebar control.
DeleteBandDeletes a band from a rebar control.
GetBandGet band information.
GetLayoutGet layout of bands in rebar.
GetRectGet band rectangle.
HeightReturns the height of the rebar control.
Id2IndexReturns 1 based position of the band with given id.
InsertInserts a new band in a rebar control.
LockLocks or unlcoks the rebar (sets or removes “nogripper” style for all bands in rebar)
MoveBandMoves a band from one index to another.
SetBandSets characteristics of an existing band in a rebar control.
SetBandStateMinimize or maximize the band.
SetBandWidthSets the width for a band.
SetBandStyleSets the style for a band.
SetLayoutSet layout of bands in rebar.
SizeToRect
ShowBandShows or hides the band.
Example
About

Add

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

Add a rebar to the GUI.

Parameters

hGuiHandle of the GUI.
StyleWhite space separated list of styles.  See bellow for details.  By default “VARHEIGHT DBLCLKTOGGLE”.  Integer styles are allowed.
hILHandle of the image list associated with the control.  Optional.
PosPosition of the rebar in usual AHK style.  Optional.
HandlerNotification handler.

Styles

autosizeThe rebar control will automatically change the layout of the bands when the size or position of the control changes.
bandbordersThe rebar control displays narrow lines to separate adjacent bands.
dblclktoggleThe 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.
fixedorderThe rebar control always displays bands in the same order.  You can move bands to different rows, but the band order is static.
varheightThe 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.
verticalgripperThe size grip will be displayed vertically instead of horizontally in a vertical rebar control.
verticalCauses the control to be displayed vertically.

Handler

Handler(hCtrl, Event)
EventC (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

WhichBandBand 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

WhichBandBand position or ID.
pQQuery parameter: S (Style), L (Length), C (Color), I (Icon index), T (Text), N (identificatioN), B (Bitmap handle).
o1..o7Reference 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

WhichBandBand position or ID.  Leave blank to get dimensions of the rebar control itself.
pQQuery parameter: set x,y,w,h to return appropriate value, or leave blank to return all in single line.
o1 .. o4Output 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

IdID 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

hCtrlControl to be hosted by the band.
o1 .. o8Named parameters.  See below.

Named parameters

SBand styles separated by white space.  By default “gripperalways”.  See bellow.
LLength of the band.  By default, width of the child control is used + 10px
mWMinimum width of the child control.
mHMinimum height of the child control.  By default the height of the child control.
IHeader icon index.
THeader text.
CBackground and foreground color separated by space.
BGBackground bitmap.
P1-based position of the band.  Set to 0 add the band to the end (default).

Band styles

breakThe band is on a new line.
childedgeThe band has an edge at the top and bottom of the child window.
fixedbmpThe background bitmap does not move when the band is resized.
fixedsizeThe band can’t be sized.  With this style, the sizing grip is not displayed on the band.
gripperalwaysThe band will always have a sizing grip, even if it is the only band in the rebar.
hiddenThe 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.
nogripperThe band will never have a sizing grip, even if there is more than one band in the rebar.
usechevronShow a chevron button if the band is smaller than ideal.
novertDon’t show when vertical.
hidetitleKeep 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

LockLeave 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

From1-based index of the band to be moved.
To1-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

WhichBandBand position or ID that is about to be changed.
o1 .. o9Named 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

WhichBandBand position or ID.  Leave blank to get dimensions of the rebar control itself.
StateSet “-” 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

WhichBandBand position or ID.
WidthWidth.

Returns

TRUE if the value was set and FALSE otherwise.

SetBandStyle

Rebar_SetBandStyle(hRebar,
WhichBand,
Style)

Sets the style for a band.

Parameters

WhichBandBand position or ID.
StyleList 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

LayoutString 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

RECTReference 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

WhichBandBand position or ID.  Leave blank to get dimensions of the rebar control itself.
bShowTrue 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

Example

    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
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