GuiPro is a Win32 DLL that places native Windows objects (buttons, checkboxes, edit fields, combo lists, menus, group boxes, etc.) on the MetaTrader 4 chart window. Get access to the GuiPro functionality by using #import guipro.mqh in your MQL4 code.
- Platform: Windows 32-bit.
- Session model:
guiInitreturns a GuiPro session id; pass it as the first argument to every othergui* call for that program.
1. Place guipro.dll in:
MetaQuotes\Terminal\<terminal-id>\MQL4\Libraries\
2. Place guipro.mqh in:
MetaQuotes\Terminal\<terminal-id>\MQL4\Include\
GuiPro Session ID
guiInit returns an integer session id (gui_id). Store it and pass it to every gui* call for that indicator instance. A return value of 0 means initialization failed (invalid chart window or internal error); do not pass 0 to other APIs.
Per-Program Isolation (short_name)
When you call guiInit(WindowHandle(_Symbol, _Period), "MyIndicator", …), the non-empty short_name partitions the in-memory save/restore cache between indicators on the same chart. The no-arg guiInit() wrapper uses MQLInfoString(MQL_PROGRAM_NAME) automatically.
Logical vs Physical Pixels
You supply positions and sizes in logical pixels (what you type in MQL). The DLL scales to physical pixels using the chart window DPI recorded at guiInit. Getters for GUI_OBJPROP_POSX, POSY, WIDTH, and HEIGHT return logical values so set/get round-trips match your literals.
Autostate Cache
By default, GuiPro snapshots checkbox, radio, edit, dropdown, and tracked menu state on guiDeinit and restores it on the next guiInit for the same chart + short_name. This survives timeframe changes and recompiles within one MT4 process. It is not persisted to disk (lost when MT4 exits). Pass autostate_enabled = 0 to disable.
Neutral Return Values + guiGetLastError
Many getters return neutral values on failure (0, empty string). The authoritative signal is guiGetLastError(gui_id), similar to checking GetLastError() after native chart-object getters. See Error handling.