WklSplitter
WklSplitter class
Signature
Dim myWklSplitter As WklSplitter Set myWklSplitter = Me!ControlName.Object
Summary
A bar between two areas of a form that the user drags at run time: the controls on its first side grow or shrink, those on its second side move their near edge with it.
Parameters
None
Remarks
Place the splitter in the gap between two areas - for example a list box and a subform - with its long side along the gap. Without further settings, the controls lying alongside the bar within 20 pixels are its areas (FirstAreas, SecondAreas); FirstControls and SecondControls name them explicitly. Areas should not be anchored: Access stretches anchored controls when the window changes size, and the splitter computes from the positions of the design.
Every arrangement is computed from the design of the form and one number, the offset of the bar (Position, in twips), plus the collapsed side (Collapsed). Offset 0 is the design exactly. A drag shows a half-transparent bar while the mouse moves and arranges the areas once, when the button is released; Esc cancels the drag. A double click folds the side named by CollapseSide away and unfolds it again.
Position, Collapsed and Layout act only in form view and are not saved with the form, so a run-time arrangement never changes the design.
Without any code, the splitter remembers the arrangement per Windows user (AutoSaveLayout, on by default): every change by the user or by code is stored, and the next time the form opens the arrangement comes back. In Access it goes into the local table USysWklLayout of the database (created with the first stored arrangement; one row per Windows user and layout, so a front end shared by several users keeps them apart); on Excel and Word UserForms into the registry of the current user. An arrangement equal to the design is not stored, so Reset removes it. Layout remains for code that keeps arrangements elsewhere: a text set before the form shows wins over the remembered one.
Keyboard: the bar is a tab stop. With the focus on it, the arrow keys along its direction move it by 8 pixels (Ctrl+arrow by 1 pixel), Home and End move it to the limits the minimum sizes allow, and Enter or Space fold the side named by CollapseSide away and back; Tab and Shift+Tab go on to the next control. Each key raises BeforeSplit and AfterSplit like a drag, and the bar keeps the focus although Access rebuilds its window after every move. UI Automation presents the bar as a slider (UI Automation Thumb) named after its areas („Splitter between lstCustomers and sfDetails“) with its offset in twips as value between the limits, which a client can set, and an expand/collapse state for the folded side.
On Excel and Word UserForms the splitter works the same; positions there are points, and the splitter converts them, so Position and the minimum sizes are twips on both (1 point = 20 twips).
An ActiveX control: inserted into a form in design view (Form Design › Controls › ActiveX Controls); reports are not supported. VBA reaches it through the Object property of the control, where ControlName is the name of the control on the form.
| Member | Kind | Summary |
|---|---|---|
| `Orientation` | Property | Gets or sets the direction of the bar. |
| `FirstControls` | Property | Gets or sets the names of the controls left of or above the bar. |
| `SecondControls` | Property | Gets or sets the names of the controls right of or below the bar. |
| `MinSizeFirst` | Property | Gets or sets the smallest width (vertical bar) or height (horizontal bar) each control on the first side keeps when the bar moves. |
| `MinSizeSecond` | Property | Gets or sets the smallest width or height each control on the second side keeps when the bar moves. |
| `Position` | Property | Gets or sets the offset of the bar from its place in the design. |
| `Collapsed` | Property | Gets or sets the side that is folded away. |
| `CollapseSide` | Property | Gets or sets the side a double click on the bar folds away and unfolds. |
| `Layout` | Property | Gets or sets the offset and the collapsed side as text, to keep a user's arrangement. |
| `BackColor` | Property | Gets or sets the color of the bar. |
| `FirstAreas` | Property | Returns the names of the controls the bar moves on its first side, found by name or by position. |
| `SecondAreas` | Property | Returns the names of the controls the bar moves on its second side. |
| `Refresh` | Method | Reads the positions of bar and areas anew from the form, for example after code moved or resized controls; the offset becomes 0, hidden areas are shown again, and the remembered arrangement of the user is removed. |
| `Reset` | Method | Restores the design: offset 0, no side collapsed. The remembered arrangement of the user is removed. |
| `AutoSaveLayout` | Property | Gets or sets whether the splitter remembers the arrangement per Windows user and restores it when the form opens. |
| `LayoutKey` | Property | Gets or sets the name under which the arrangement is remembered. |
| `ColorScheme` | Property | Gets or sets the color scheme the control draws in. |
| Event | Summary |
|---|---|
| `BeforeSplit` | Occurs after the user released the dragged bar, before the areas move. |
| `AfterSplit` | Occurs after the areas moved because the user dragged the bar. |
| `AfterCollapse` | Occurs after a side was folded away or unfolded, by double click or by setting Collapsed. |
Code example
' The splitter remembers each user's arrangement by itself. This form is opened once per
' customer (OpenArgs), and each customer gets an arrangement of its own.
Private Sub Form_Open(Cancel As Integer)
Me!Split1.Object.LayoutKey = "frmOrders.Split1." & Nz(Me.OpenArgs, "")
End Sub
Inheritance
None
Orientation property
Signature
Property Get Orientation() As WklSplitOrientation Property Let Orientation(RHS As WklSplitOrientation)
Summary
Gets or sets the direction of the bar.
Parameters
None
Property value: `WklSplitOrientation` – wsoVertical (default): a vertical bar between areas on its left and right, dragged sideways; wsoHorizontal: a horizontal bar between areas above and below.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklSplitter.
FirstControls property
Signature
Property Get FirstControls() As String Property Let FirstControls(RHS As String)
Summary
Gets or sets the names of the controls left of or above the bar.
Parameters
None
Property value: String – Control names separated by semicolons; empty (default): the controls lying alongside the bar within 20 pixels.
Remarks
A name the form does not have raises wkeInvalidValue when the splitter first arranges. Changing the value in form view makes the splitter read its areas anew, as Refresh does.
Read/write.
Code example
None
Inheritance
Declared by WklSplitter.
SecondControls property
Signature
Property Get SecondControls() As String Property Let SecondControls(RHS As String)
Summary
Gets or sets the names of the controls right of or below the bar.
Parameters
None
Property value: String – Control names separated by semicolons; empty (default): the controls lying alongside the bar within 20 pixels.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklSplitter.
MinSizeFirst property
Signature
Property Get MinSizeFirst() As Long Property Let MinSizeFirst(RHS As Long)
Summary
Gets or sets the smallest width (vertical bar) or height (horizontal bar) each control on the first side keeps when the bar moves.
Parameters
None
Property value: Long – Twips; default 0.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklSplitter.
MinSizeSecond property
Signature
Property Get MinSizeSecond() As Long Property Let MinSizeSecond(RHS As Long)
Summary
Gets or sets the smallest width or height each control on the second side keeps when the bar moves.
Parameters
None
Property value: Long – Twips; default 0.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklSplitter.
Position property
Signature
Property Get Position() As Long Property Let Position(RHS As Long)
Summary
Gets or sets the offset of the bar from its place in the design.
Parameters
None
Property value: Long – Twips; positive moves the bar right or down. Limited by the minimum sizes of both sides.
Remarks
Setting the value arranges bar and areas at once and raises no event, like a value set by code on an Access control. In design view the value is kept but nothing moves.
Read/write.
Code example
None
Inheritance
Declared by WklSplitter.
Collapsed property
Signature
Property Get Collapsed() As WklSplitCollapse Property Let Collapsed(RHS As WklSplitCollapse)
Summary
Gets or sets the side that is folded away.
Parameters
None
Property value: `WklSplitCollapse` – wscNone (default), wscFirst or wscSecond.
Remarks
The controls of a collapsed side are hidden and the other side takes their room; wscNone shows them again at the offset the user had. Raises AfterCollapse when the side changes. Access refuses to hide the control that has the focus; that area then stays visible under the other side.
Read/write.
Code example
None
Inheritance
Declared by WklSplitter.
CollapseSide property
Signature
Property Get CollapseSide() As WklSplitCollapse Property Let CollapseSide(RHS As WklSplitCollapse)
Summary
Gets or sets the side a double click on the bar folds away and unfolds.
Parameters
None
Property value: `WklSplitCollapse` – wscFirst (default), wscSecond, or wscNone to switch the double click off.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklSplitter.
Layout property
Signature
Property Get Layout() As String Property Let Layout(RHS As String)
Summary
Gets or sets the offset and the collapsed side as text, to keep a user's arrangement.
Parameters
None
Property value: String – JSON text such as {"format":"WklSplitter","version":1,"offset":700,"collapsed":"none"}; an empty string restores the design.
Remarks
Setting a text not written by a WklSplitter raises wkeInvalidValue.
Read/write.
Code example
None
Inheritance
Declared by WklSplitter.
BackColor property
Signature
Property Get BackColor() As OLE_COLOR Property Let BackColor(RHS As OLE_COLOR)
Summary
Gets or sets the color of the bar.
Parameters
None
Property value: OLE_COLOR – An OLE_COLOR; default the system color for buttons (vbButtonFace).
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklSplitter.
FirstAreas property
Signature
Property Get FirstAreas() As String
Summary
Returns the names of the controls the bar moves on its first side, found by name or by position.
Parameters
None
Property value: String – Control names separated by semicolons; empty in design view.
Remarks
Read-only.
Code example
None
Inheritance
Declared by WklSplitter.
SecondAreas property
Signature
Property Get SecondAreas() As String
Summary
Returns the names of the controls the bar moves on its second side.
Parameters
None
Property value: String – Control names separated by semicolons; empty in design view.
Remarks
Read-only.
Code example
None
Inheritance
Declared by WklSplitter.
Refresh method
Signature
Sub Refresh()
Summary
Reads the positions of bar and areas anew from the form, for example after code moved or resized controls; the offset becomes 0, hidden areas are shown again, and the remembered arrangement of the user is removed.
Parameters
None
Remarks
None
Code example
None
Inheritance
Declared by WklSplitter.
Reset method
Signature
Sub Reset()
Summary
Restores the design: offset 0, no side collapsed. The remembered arrangement of the user is removed.
Parameters
None
Remarks
None
Code example
None
Inheritance
Declared by WklSplitter.
AutoSaveLayout property
Signature
Property Get AutoSaveLayout() As Boolean Property Let AutoSaveLayout(RHS As Boolean)
Summary
Gets or sets whether the splitter remembers the arrangement per Windows user and restores it when the form opens.
Parameters
None
Property value: Boolean – True (default) or False.
Remarks
The arrangement is restored once, when the splitter first shows in form view, and stored after every change. Set the value to False in the property sheet, or in Form_Open, to keep each opening at the design - for example when code restores arrangements from a table of its own through Layout. Switching it off does not remove what was stored.
Storage: in Access the table USysWklLayout (fields UserName as DOMAIN\name, LayoutKey, Layout, Changed); Access treats tables named USys... as system tables and hides them unless system objects are shown. On UserForms the registry key HKEY_CURRENT_USER\Software\The White Knight Labs\Access Framework\Layouts, one value per LayoutKey. A database opened read-only cannot store; the arrangement is then simply not remembered.
Read/write.
Code example
None
Inheritance
Declared by WklSplitter.
LayoutKey property
Signature
Property Get LayoutKey() As String Property Let LayoutKey(RHS As String)
Summary
Gets or sets the name under which the arrangement is remembered.
Parameters
None
Property value: String – Text of up to 255 characters; empty (default): the name of the form and of the control, such as frmOrders.Split1.
Remarks
Set a key of its own when the same form must keep several arrangements (one per customer, one per purpose), or on UserForms, where UserForm1.Split1 in two workbooks would share one arrangement. Set it in the property sheet or in Form_Open, before the splitter first shows.
Read/write.
Code example
None
Inheritance
Declared by WklSplitter.
ColorScheme property
Signature
Property Get ColorScheme() As WklColorScheme Property Let ColorScheme(RHS As WklColorScheme)
Summary
Gets or sets the color scheme the control draws in.
Parameters
None
Property value: `WklColorScheme` – wcoAutomatic (default), wcoLight, wcoDark or wcoHighContrast.
Remarks
wcoAutomatic follows, in this order, Windows high contrast mode, then the color set of the database design (Access: Design › Themes or Colors), and draws light when the database has no design or the control is on an Excel or Word UserForm. Office's own design setting and the Windows app mode are not followed: a database looks the same on every PC. In high contrast mode the control always uses the system colors. The scheme colors the bar (while BackColor keeps the system default) and its grip dots; a BackColor you set wins over the scheme. Every text keeps a contrast of at least 4.5:1. The control reads the database design after it is first drawn, never while Access draws the form, and again when the form opens anew. The value is saved with the form.
Read/write.
Code example
None
Inheritance
Declared by WklSplitter.
BeforeSplit event
Signature
Event BeforeSplit(ByRef Position As Long, ByRef Cancel As Integer)
Summary
Occurs after the user released the dragged bar, before the areas move.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Position | Long (by reference) | No | – | The offset the bar will have, in twips; the handler may change it. |
Cancel | Integer (by reference) | No | – | Set to True to leave everything as it was. |
Remarks
In a form module: Private Sub <ControlName>_BeforeSplit(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklSplitter.
AfterSplit event
Signature
Event AfterSplit(ByVal Position As Long)
Summary
Occurs after the areas moved because the user dragged the bar.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Position | Long | No | – | The new offset in twips. |
Remarks
In a form module: Private Sub <ControlName>_AfterSplit(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklSplitter.
AfterCollapse event
Signature
Event AfterCollapse(ByVal Side As WklSplitCollapse)
Summary
Occurs after a side was folded away or unfolded, by double click or by setting Collapsed.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Side | `WklSplitCollapse` | No | – | The collapsed side, or wscNone when the areas were unfolded. |
Remarks
In a form module: Private Sub <ControlName>_AfterCollapse(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklSplitter.