Programming with Splitter Controls
- Updated2023-02-21
- 2 minute(s) read
Programming with Splitter Controls
This topic describes how to complete the following tasks programmatically.
- Adding a control to the splitter control
- Adding a panel to the splitter control
- Operating controls or panels that are attached to the splitter control
- Removing a control or panel from the splitter control
Adding a Control to the Splitter Control
You must call the AddCtrlToSplitter function to attach a control to a splitter control. Controls you attach using these functions must already be created.
You can attach controls programmatically or through the User Interface Editor.
// The fifth parameter specifies that the Quit button will attach to the left side of the splitter and the sixth parameter specifies that moving the splitter causes the Quit button to change size.
AddCtrlToSplitter (panelHandle, PANEL_SPLITTER, VAL_LEFT_ANCHOR, PANEL_QUITBUTTON, 1, 0);

Adding a Panel to the Splitter Control
You must call the AddPanelToSplitter function to attach a panel to a splitter control. Panels you attach using these functions must already be created.
You can attach child panels to splitter controls only programmatically.
AddPanelToSplitter (panelHandle, PANEL_SPLITTER, VAL_BOTTOM_ANCHOR, subPanelHandle, 0, 0);
Removing a Control or Panel from the Splitter Control
Use RemoveCtrlFromSplitter and RemovePanelFromSplitter to remove a control or panel from the splitter control.
RemoveCtrlFromSplitter (panelHandle, PANEL_SPLITTER, PANEL_QUITBUTTON);
RemovePanelFromSplitter (panelHandle, PANEL_SPLITTER, subPanelHandle);
Operating Controls or Panels that are Attached to the Splitter Control
Use the OperateSplitter function to programmatically operate the splitter and its attached controls and panels. With OperateSplitter, you can provide better panel scaling than with the ATTR_SCALE_CONTENTS_ON_RESIZE attribute. You can use OperateSplitter to respond to panel size events to customize the internal scaling of the panel. Refer to the samples\userint\docking.cws example for more information about using OperateSplitter.
// Size or move any controls or panels that are attached to the splitter. The last parameter represents the number of pixels you want to offset the position of the splitter control.
OperateSplitter (panelHandle, PANEL_SPLITTER, 25);