SbrPanels class
The collection of the panels of a StatusBar, which its Panels property returns. Its items are SbrPanel objects, numbered from 1 from the left, and an item can have a key as well.
A program goes through the panels with For Each, or by number from 1 to Count. It cannot make an SbrPanels object with New.
Numbers and keys
The number of a panel is its place in the bar, counted from the left. It changes when a panel is added before it or removed before it, so a program that keeps a number over such a change keeps the wrong panel. A key stays with its panel.
A key is any string. No two panels of a bar have the same key. A panel needs no key: an empty string is no key, and any number of panels can be without one.
Dim Panel As SbrPanel
StatusBar1.Panels.Add , "pos", "Ln 1"
StatusBar1.Panels.Add 1, "mode", "Insert" ' before the first
For Each Panel In StatusBar1.Panels
Debug.Print Panel.Index; "["; Panel.Key; "]"
Next
StatusBar1.Panels.Remove "mode"
Debug.Print StatusBar1.Panels("pos").Index
' Output:
' 1 [mode]
' 2 []
' 3 [pos]
' 2
Properties
Count
The number of panels in the bar. Long, read-only. A bar can have at most 255 panels.
Item
Returns one panel. It is the default member, so StatusBar1.Panels("pos") is StatusBar1.Panels.Item("pos").
Syntax: object.Item( Index ) As SbrPanel
- Index
- required The number of the panel, from 1 to Count, or its key as a String.
A number outside that range raises run-time error 9, and a key that no panel has raises run-time error 5. Exists asks without an error.
Methods
Add
Makes a panel and returns its SbrPanel.
Syntax: object.Add( [ Index ] [, Key ] [, Text ] [, Style ] ) As SbrPanel
- Index
- optional A Long: the number the new panel gets. The panels from that number on move up by one. Without it, or with 0, the panel goes after the last one.
- Key
- optional A String by which the program can name the panel. See Numbers and keys.
- Text
- optional A String: the panel’s Text. The default is empty.
- Style
- optional A member of SbrPanelStyleConstants: what the panel shows. The default is SbrPanelStyleText.
A new panel has the values that SbrPanel gives as defaults. The call has no argument for a picture, so a program sets Picture afterward.
A negative Index, and one greater than Count + 1, raises run-time error 35600, Index out of bounds. A call that would make the 256th panel raises run-time error 35616, Maximum Panels Exceeded.
A Key that another panel has raises run-time error 457, and nothing is added.
Warning 1.8.141.0
A Style that is not a member of SbrPanelStyleConstants raises run-time error 380 after the panel has been added. The collection keeps the new panel, with its key and its text, and the bar’s window does not show it until another change lays the panels out again. A program checks the value before the call.
Clear
Removes every panel. A bar with no panels shows an empty strip, and Add makes the first panel again.
Syntax: object.Clear
A program that clears the bar adds the panels it needs again: the panel that a new bar has is removed too.
Exists
Returns whether the bar has a panel of a number or a key, so that a program can ask before Item raises an error.
Syntax: object.Exists( Index ) As Boolean
- Index
- required The number or the key to look for.
Remove
Removes one panel. The panels after it move down by one.
Syntax: object.Remove Index
- Index
- required The number or the key of the panel. One that the bar does not have raises the error that Item raises for it.