Tab Container Widget
MQL4 chart objects have no native "hidden" flag, so most hand-built tabbed panels solve tab switching one of two bad ways: delete and recreate every object each time a tab is selected (slow, and it throws away any state a control was holding, such as text already typed into an edit box), or never solve it at all and draw every tab's content stacked on top of every other tab's at once. This widget uses OBJPROP_TIMEFRAMES instead - the property that controls which chart timeframes an object is visible on. Setting it to OBJ_NO_PERIODS hides the object everywhere, OBJ_ALL_PERIODS restores it. The chart's actual timeframe never changes; the property is used purely as an on/off switch, so a tab switch is one ObjectSetInteger() call per registered object and the object itself is never touched otherwise. The widget only owns the tab-header buttons. RegisterContent(objectName,tab) associates an already-existing chart object - built and owned by the caller, of any object type - with the tab that should show it. This keeps the widget generic: it never needs to know what an "edit box" or a "checkbox" is, it only needs a name and a tab index, so any mix of labels, buttons, rectangles or edit objects can live inside a tab. Notes and limitations - Up to 12 tabs and up to 64 registered content objects total (TCW_MAX_TABS / TCW_MAX_CONTENT), fixed-size arrays sized for a settings-panel scale, not a dynamic collection. - RegisterContent() requires the object to already exist - the widget never creates content on the caller's behalf, only tracks visibility for it. - OBJPROP_TIMEFRAMES is a real, general MQL4 object property, not a trick specific to any one object type - it works identically on labels, buttons, rectangles, edit objects and any other object type used as tab content. - No trading and no money at risk - the demo only builds and switches between panel-style labels, it never sends an order.
Script · MT5 · v1.0 · Free
About Tab Container Widget
Tab Container Widget is a script for MetaTrader 5. It has 1 setting, such as Prefix. MQL source code included.
Files in the download: TabContainerWidget.mq5.mqh, TabContainerWidget.txt, TabContainerWidgetDemo.ex5, TabContainerWidgetDemo.mq5.
Settings
| Setting | Default | What it does |
|---|---|---|
| Prefix | TCWDemo_ | Object-name prefix for this demo's objects |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: MT5 Script · MQL5 Source Code