DPI and Scaling
ModernUI lays out panels in logical units.
By default, MuiRoot uses compensated DPI behaviour so Windows display scaling does not simply enlarge the whole panel.
This helps the UI stay a consistent fraction of the chart across PCs, laptops, and VPS sessions.
Default mode
The default DPI mode is:
MUI_DPI_COMPENSATED
This means higher Windows display scaling does not automatically make the entire UI larger.
Native DPI mode
Use native DPI mode if you prefer legacy behaviour where higher Windows DPI enlarges the UI.
g_ui.DpiMode(MUI_DPI_NATIVE);
Manual scale
Use manual scale when you want explicit control.
g_ui.SetScale(1.15);
SetScale(...) selects manual DPI mode.
You can also use:
g_ui.UiScale(1.15);
Use the mode that matches your app’s intended behaviour.
Diagnostics
Log DPI diagnostics when testing across machines.
g_ui.LogDpiDiagnostics();
The package includes a DPI validation example:
Examples/ModernUI_DpiValidation.mq5
Use it to compare terminal DPI, DPI scale, effective scale, and chart pixels across display scales.
Where to set DPI/scale
Set DPI mode or manual scale after Init and before building the UI.
if(!g_ui.Init(ChartID(),0,"MyUI_",512,16))
return(INIT_FAILED);
g_ui.DpiMode(MUI_DPI_COMPENSATED);
g_ui.UiScale(1.0);
MuiAppWindow app=Mui::AppWindow(g_ui,"Panel",20,40,340,430,true);
Practical guidance
| Situation | Recommendation |
|---|---|
| General public product | Use default compensated mode |
| You want Windows DPI to enlarge the UI | Use native mode |
| You want a user-controlled zoom setting | Use manual scale |
| Testing across PCs/VPS | Use DPI diagnostics |
| Screenshots look inconsistent across machines | Check DPI mode and manual scale |
Common mistakes
Assuming Windows scaling always enlarges the UI
Default compensated mode avoids that.
Changing scale without expecting layout changes
Scale changes affect layout and repaint.
Comparing screenshots across PCs without checking DPI
Use diagnostics before assuming a layout bug.