Build an adjustable two-pane view
Separate navigation and detail with a movable splitter.
The splitter belongs to the container, not to either pane’s content. Use SplitterMoved to observe a completed layout change. Check the minimum practical size of each pane so moving the divider does not make a task impossible.
Step 1Prepare a safe practice project#
Extract the archive into a new writable folder, separate from your own application. Open SplitContainer.mcbproj in McBasic™. Keep every declared source, layout, resource and migration file together.
To reconstruct it yourself, create a DesktopApp project and add the files declared below. In the complete project, follow these steps as a guided rebuild: replace each named source file once and Check after all its procedures are present.
Exact project configuration
{
"schemaVersion": 1,
"projectId": "2bb72e26-0e38-4d95-88ee-1a34de7d31ea",
"name": "SplitContainerSample",
"kind": "DesktopApp",
"ai": {
"storeChatsInProject": false
},
"language": {
"dialect": "McBasic1",
"requireExplicit": true,
"compare": "Binary",
"defaultArrayBase": 0
},
"application": {
"bundleIdentifier": "com.mcbasic.samples.splitcontainer",
"version": "0.1.0",
"buildNumber": "1",
"startupFormId": "form-main",
"shutdownMode": "OnStartupFormClosed"
},
"forms": [
{
"id": "form-main",
"typeName": "frmMain",
"layout": "Forms/frmMain.form.json",
"code": "Forms/frmMain.bas"
}
],
"modules": [],
"classes": [],
"tests": [],
"references": [],
"resources": [],
"targets": [
"osx-arm64"
],
"capabilities": []
}Step 2Build the Form and set its properties#
frmMain
Select the Form first and set its properties. Add containers before their children. These are initial Designer values, not statements to paste into a procedure.
| Form property | Value |
|---|---|
Caption | "SplitContainer — McBasic" |
Width | 720 |
Height | 420 |
MinWidth | 560 |
MinHeight | 320 |
| Type | Name | Parent |
|---|---|---|
| SplitContainer | splitMain | Form |
| Panel | pnlLeft | splitMain |
| Panel | pnlRight | splitMain |
| Label | lblLeft | pnlLeft |
| Label | lblRight | pnlRight |
| StatusBar | staStatus | Form |
| CommandButton | cmdClose | Form |
splitMain · exact Inspector values
| Property | Value |
|---|---|
Left | 32 |
Top | 28 |
Width | 656 |
Height | 290 |
Orientation | "Horizontal" |
Ratio | 0.42 |
SplitterWidth | 6 |
FirstPaneMinSize | 120 |
SecondPaneMinSize | 160 |
IsSplitterFixed | False |
FixedPane | "None" |
FirstPaneCollapsed | False |
SecondPaneCollapsed | False |
TabIndex | 0 |
| Anchor edges | Left, Right, Top, Bottom |
pnlLeft · exact Inspector values
| Property | Value |
|---|---|
Left | 16 |
Top | 16 |
Width | 240 |
Height | 250 |
TabIndex | 0 |
| Anchor edges | Left, Top |
pnlRight · exact Inspector values
| Property | Value |
|---|---|
Left | 16 |
Top | 16 |
Width | 300 |
Height | 250 |
TabIndex | 1 |
| Anchor edges | Left, Top |
lblLeft · exact Inspector values
| Property | Value |
|---|---|
Left | 20 |
Top | 24 |
Width | 180 |
Height | 30 |
Caption | "First pane" |
TabIndex | 0 |
| Anchor edges | Left, Top |
lblRight · exact Inspector values
| Property | Value |
|---|---|
Left | 20 |
Top | 24 |
Width | 220 |
Height | 30 |
Caption | "Second pane" |
TabIndex | 0 |
| Anchor edges | Left, Top |
staStatus · exact Inspector values
| Property | Value |
|---|---|
Left | 32 |
Top | 354 |
Width | 430 |
Height | 26 |
Text | "Ready" |
TabIndex | 1 |
| Anchor edges | Left, Bottom |
cmdClose · exact Inspector values
| Property | Value |
|---|---|
Left | 560 |
Top | 348 |
Width | 128 |
Height | 36 |
Caption | "Close" |
TabIndex | 2 |
| Anchor edges | Right, Bottom |
Step 3Connect the events explicitly#
frmMain
| Object | Event | Procedure | Parameters |
|---|---|---|---|
splitMain | SplitterMoved | splitMain_SplitterMoved | SplitterMoved() |
cmdClose | Click | cmdClose_Click | Click() |
| Form | Load | Form_Load | () |
Step 4Enter the complete behavior#
Open the named source file. Enter declarations first, then every procedure. Expand a procedure for its full body, or copy the complete file. Helpers are required: do not stop after entering the first Click handler.
Forms/frmMain.bas
Enter these declarations at file scope, before the procedures.
Option ExplicitPrivate Sub Form_Load()
Initialize state before enabling dependent actions. Keep the shared declarations and startup dependencies with this procedure.
Private Sub Form_Load()
splitMain.Orientation = "Horizontal"
splitMain.Ratio = 0.42
splitMain.SplitterWidth = 6
splitMain.FirstPaneMinSize = 120
splitMain.SecondPaneMinSize = 160
splitMain.IsSplitterFixed = False
splitMain.FixedPane = "None"
splitMain.FirstPaneCollapsed = False
splitMain.SecondPaneCollapsed = False
lblLeft.Caption = "First pane"
lblRight.Caption = "Second pane"
staStatus.Text = "SplitContainer ready"
End SubPrivate Sub splitMain_SplitterMoved()
Enter this helper in the named source file, outside every other procedure. Its callers are included in the same project.
Private Sub splitMain_SplitterMoved()
staStatus.Text = "Splitter moved — ratio " & CStr(splitMain.Ratio) & ", position " & CStr(splitMain.SplitterPosition)
End SubPrivate Sub cmdClose_Click()
Enter the complete action, including its input checks and calls to helper procedures.
Private Sub cmdClose_Click()
Unload Me
End SubCopy the complete Forms/frmMain.bas file
Replace the file once; do not append duplicate procedures.
Option Explicit
Private Sub Form_Load()
splitMain.Orientation = "Horizontal"
splitMain.Ratio = 0.42
splitMain.SplitterWidth = 6
splitMain.FirstPaneMinSize = 120
splitMain.SecondPaneMinSize = 160
splitMain.IsSplitterFixed = False
splitMain.FixedPane = "None"
splitMain.FirstPaneCollapsed = False
splitMain.SecondPaneCollapsed = False
lblLeft.Caption = "First pane"
lblRight.Caption = "Second pane"
staStatus.Text = "SplitContainer ready"
End Sub
Private Sub splitMain_SplitterMoved()
staStatus.Text = "Splitter moved — ratio " & CStr(splitMain.Ratio) & ", position " & CStr(splitMain.SplitterPosition)
End Sub
Private Sub cmdClose_Click()
Unload Me
End SubStep 5Keep resources and storage reproducible#
No external resource or migration files are declared. Any inline migration, seed data or local JSON is present in the code above. Runtime application data and private preferences are not included in the archive.
Step 6Check, run and test the result#
Save all files and run Check. Resolve diagnostics before Run. Developer CLI users can work from the extracted folder:
mcbasic check SplitContainer.mcbproj
mcbasic run SplitContainer.mcbprojAcceptance checklist
- Move the divider in both directions.
- Inspect the reported splitter state.
- Resize the entire Form and repeat.
Step 7Make one change and repeat the tests#
Replace the pane labels with a list and detail field while preserving correct parenting.
Save a working Git checkpoint first. Change one behavior, Check again and repeat the acceptance checklist. Compare with the downloaded solution if a regression appears.
20f4bfed6b · Build manifest