DoEasy. 控件 (第 9 部分): 重新编排 WinForms 对象方法、RadioButton 和 Button 控件·进阶篇
(2/3)· 把散落的控件属性收编进单一框架,MT5 自定义 UI 的维护成本可能直接砍半
「控件属性枚举里的交互状态字段」
在 MT5 的 Canvas 控件库里,元素属性用一组 CANV_ELEMENT_PROP_* 枚举值描述,其中有一批专门管交互视觉反馈,容易被忽略但直接影响盘面板的可读性。 比如 CANV_ELEMENT_PROP_BACKGROUND_COLOR_MOUSE_DOWN 与 _MOUSE_OVER,分别定义鼠标按下和悬停时的背景色;边框同理有 CANV_ELEMENT_PROP_BORDER_COLOR_MOUSE_DOWN / _MOUSE_OVER。若不显式赋值,控件在 hover 或点击时不会变色,盯盘面板容易显得「死」。 带勾选框的控件还有独立的一套:CANV_ELEMENT_PROP_CHECK_BACKGROUND_COLOR 系列四个状态色,加 CANV_ELEMENT_PROP_CHECK_STATE(是否勾选)和 CANV_ELEMENT_PROP_AUTOCHECK(选中时是否自动翻转状态)。写开关类指标时,用 AUTOCHECK 能省掉手动维护状态的代码。 实测中若只设了默认 BACKGROUND_COLOR 而没设 _OPACITY,控件背景可能完全不透明挡住底层 K 线——外汇与贵金属图表高频刷新,这种遮挡会干扰价格行为判断,属高风险界面 bug,开 MT5 拖一个 Canvas 按钮就能复现。
CANV_ELEMENT_PROP_ACT_BOTTOM, class=class="str">"cmt">// Bottom border of the element active area CANV_ELEMENT_PROP_ZORDER, class=class="str">"cmt">// Priority of a graphical object for receiving the event of clicking on a chart CANV_ELEMENT_PROP_ENABLED, class=class="str">"cmt">// Element availability flag CANV_ELEMENT_PROP_FORE_COLOR, class=class="str">"cmt">// Default text class="type">color for all control objects CANV_ELEMENT_PROP_FORE_COLOR_OPACITY, class=class="str">"cmt">// Default text class="type">color opacity for all control objects CANV_ELEMENT_PROP_BACKGROUND_COLOR, class=class="str">"cmt">// Control background class="type">color CANV_ELEMENT_PROP_BACKGROUND_COLOR_OPACITY, class=class="str">"cmt">// Non-transparency of control background class="type">color CANV_ELEMENT_PROP_BACKGROUND_COLOR_MOUSE_DOWN, class=class="str">"cmt">// Control background class="type">color when clicking on the control CANV_ELEMENT_PROP_BACKGROUND_COLOR_MOUSE_OVER, class=class="str">"cmt">// Control background class="type">color when hovering the mouse over the control CANV_ELEMENT_PROP_BOLD_TYPE, class=class="str">"cmt">// Font width type CANV_ELEMENT_PROP_BORDER_STYLE, class=class="str">"cmt">// Control frame style CANV_ELEMENT_PROP_BORDER_SIZE_TOP, class=class="str">"cmt">// Control frame top size CANV_ELEMENT_PROP_BORDER_SIZE_BOTTOM, class=class="str">"cmt">// Control frame bottom size CANV_ELEMENT_PROP_BORDER_SIZE_LEFT, class=class="str">"cmt">// Control frame left size CANV_ELEMENT_PROP_BORDER_SIZE_RIGHT, class=class="str">"cmt">// Control frame right size CANV_ELEMENT_PROP_BORDER_COLOR, class=class="str">"cmt">// Control frame class="type">color CANV_ELEMENT_PROP_BORDER_COLOR_MOUSE_DOWN, class=class="str">"cmt">// Control frame class="type">color when clicking on the control CANV_ELEMENT_PROP_BORDER_COLOR_MOUSE_OVER, class=class="str">"cmt">// Control frame class="type">color when hovering the mouse over the control CANV_ELEMENT_PROP_AUTOSIZE, class=class="str">"cmt">// Flag of the element auto resizing depending on the content CANV_ELEMENT_PROP_AUTOSIZE_MODE, class=class="str">"cmt">// Mode of the element auto resizing depending on the content class=class="str">"cmt">//--- ... class=class="str">"cmt">//--- ... CANV_ELEMENT_PROP_CHECK_STATE, class=class="str">"cmt">// Status of a control having a checkbox CANV_ELEMENT_PROP_AUTOCHECK, class=class="str">"cmt">// Auto change flag status when it is selected CANV_ELEMENT_PROP_CHECK_BACKGROUND_COLOR, class=class="str">"cmt">// Color of control checkbox background CANV_ELEMENT_PROP_CHECK_BACKGROUND_COLOR_OPACITY, class=class="str">"cmt">// Non-transparency of the control checkbox background class="type">color CANV_ELEMENT_PROP_CHECK_BACKGROUND_COLOR_MOUSE_DOWN, class=class="str">"cmt">// Color of control checkbox background when clicking on the control CANV_ELEMENT_PROP_CHECK_BACKGROUND_COLOR_MOUSE_OVER class=class="str">"cmt">// Color of control checkbox background when hovering the mouse over the control
画布控件复选框与排序属性枚举
在 MT5 自定义画布(Canvas)控件体系里,复选框(checkbox)有一组独立的前景与标记颜色属性,用来区分常态、鼠标悬停和按下三种交互状态。比如 CANV_ELEMENT_PROP_CHECK_FORE_COLOR 管边框常态色,CANV_ELEMENT_PROP_CHECK_FORE_COLOR_MOUSE_OVER 管悬停边框色,CANV_ELEMENT_PROP_CHECK_FLAG_COLOR 则是框内对勾标记本身的颜色,分别对应 MOUSE_DOWN 与 MOUSE_OVER 变体。 这些属性被归入整数属性池,宏 CANV_ELEMENT_PROP_INTEGER_TOTAL 定义为 71,即画布元素总共暴露 71 个整型属性,其中 CANV_ELEMENT_PROP_INTEGER_SKIP 为 0,表示没有整型属性被排除在排序之外。 排序枚举 ENUM_SORT_CANV_ELEMENT_MODE 直接映射整型属性偏移:FIRST_CANV_ELEMENT_DBL_PROP 由 (71 - 0) 算出,意味着双精度属性紧接着整型区排布;背景色、边框线宽等也都有对应的 SORT_BY_CANV_ELEMENT_BACKGROUND_COLOR / BORDER_SIZE_TOP 等枚举值。开 MT5 在 Include\Canvas 相关头文件搜 CANV_ELEMENT_PROP_CHECK 就能看到完整列表,调界面配色时改这几个枚举对应的属性值即可。
CANV_ELEMENT_PROP_CHECK_FORE_COLOR, class=class="str">"cmt">// Color of control checkbox frame CANV_ELEMENT_PROP_CHECK_FORE_COLOR_OPACITY, class=class="str">"cmt">// Non-transparency of the control checkbox frame class="type">color CANV_ELEMENT_PROP_CHECK_FORE_COLOR_MOUSE_DOWN, class=class="str">"cmt">// Color of control checkbox frame when clicking on the control CANV_ELEMENT_PROP_CHECK_FORE_COLOR_MOUSE_OVER, class=class="str">"cmt">// Color of control checkbox frame when hovering the mouse over the control CANV_ELEMENT_PROP_CHECK_FLAG_COLOR, class=class="str">"cmt">// Color of control checkbox CANV_ELEMENT_PROP_CHECK_FLAG_COLOR_OPACITY, class=class="str">"cmt">// Non-transparency of the control checkbox class="type">color CANV_ELEMENT_PROP_CHECK_FLAG_COLOR_MOUSE_DOWN, class=class="str">"cmt">// Color of control checkbox when clicking on the control CANV_ELEMENT_PROP_CHECK_FLAG_COLOR_MOUSE_OVER, class=class="str">"cmt">// Color of control checkbox when hovering the mouse over the control }; class="macro">#define CANV_ELEMENT_PROP_INTEGER_TOTAL(class="num">71) class=class="str">"cmt">// Total number of integer properties class="macro">#define CANV_ELEMENT_PROP_INTEGER_SKIP(class="num">0) class=class="str">"cmt">// Number of integer properties not used in sorting class="macro">#define FIRST_CANV_ELEMENT_DBL_PROP(CANV_ELEMENT_PROP_INTEGER_TOTAL-CANV_ELEMENT_PROP_INTEGER_SKIP) class="macro">#define FIRST_CANV_ELEMENT_STR_PROP(CANV_ELEMENT_PROP_INTEGER_TOTAL-CANV_ELEMENT_PROP_INTEGER_SKIP+CANV_ELEMENT_PROP_DOUBLE_TOTAL-CANV_ELEMENT_PROP_DOUBLE_SKIP) enum ENUM_SORT_CANV_ELEMENT_MODE { SORT_BY_CANV_ELEMENT_ID = class="num">0, class=class="str">"cmt">// Sort by element ID SORT_BY_CANV_ELEMENT_TYPE, class=class="str">"cmt">// Sort by graphical element type SORT_BY_CANV_ELEMENT_FORE_COLOR, class=class="str">"cmt">// Sort by class="kw">default text class="type">color for all control objects SORT_BY_CANV_ELEMENT_FORE_COLOR_OPACITY, class=class="str">"cmt">// Sort by class="kw">default text class="type">color opacity for all control objects SORT_BY_CANV_ELEMENT_BACKGROUND_COLOR, class=class="str">"cmt">// Sort by control background text class="type">color SORT_BY_CANV_ELEMENT_BACKGROUND_COLOR_OPACITY, class=class="str">"cmt">// Sort by control background class="type">color non-transparency SORT_BY_CANV_ELEMENT_BACKGROUND_COLOR_MOUSE_DOWN, class=class="str">"cmt">// Sort by control background text class="type">color when clicking on the control SORT_BY_CANV_ELEMENT_BACKGROUND_COLOR_MOUSE_OVER, class=class="str">"cmt">// Sort by control background text class="type">color when hovering the mouse over the control SORT_BY_CANV_ELEMENT_BOLD_TYPE, class=class="str">"cmt">// Sort by font width type SORT_BY_CANV_ELEMENT_BORDER_STYLE, class=class="str">"cmt">// Sort by control frame style SORT_BY_CANV_ELEMENT_BORDER_SIZE_TOP, class=class="str">"cmt">// Sort by control frame top size SORT_BY_CANV_ELEMENT_BORDER_SIZE_BOTTOM, class=class="str">"cmt">// Sort by control frame bottom size SORT_BY_CANV_ELEMENT_BORDER_SIZE_LEFT, class=class="str">"cmt">// Sort by control frame left size SORT_BY_CANV_ELEMENT_BORDER_SIZE_RIGHT, class=class="str">"cmt">// Sort by control frame right size };
◍ Canvas 控件排序枚举里的边框与勾选属性
在 MQL5 的 Canvas 图形库枚举中,控件排序维度被拆得很细。仅边框颜色一类就区分了常态、鼠标按下、鼠标悬停三种状态,对应 SORT_BY_CANV_ELEMENT_BORDER_COLOR 及其 _MOUSE_DOWN / _MOUSE_OVER 后缀。 勾选框(checkbox)相关的排序键更密集:从背景色、背景不透明度、悬停/按下背景色,到边框色、边框不透明度、勾选标记色与对应交互态,共 12 个以 SORT_BY_CANV_ELEMENT_CHECK_ 开头的枚举值。做自定义面板排序时,若想按交互视觉状态重排控件,这些键是直接可用的。 字符串类排序从 FIRST_CANV_ELEMENT_STR_PROP 起算,包含对象名、资源名与元素文本(SORT_BY_CANV_ELEMENT_NAME_OBJ / NAME_RES / TEXT)。在 MT5 里打开对应库头文件搜 SORT_BY_CANV_ELEMENT_CHECK_BACKGROUND_COLOR_OPACITY,能确认非透明度维度独立成键,不是和颜色混在一个属性里。 外汇与贵金属图表上挂这类 Canvas 面板存在报价断流导致重绘异常的高风险,验证时建议先在分钟周期离线测试。
SORT_BY_CANV_ELEMENT_BORDER_COLOR, class=class="str">"cmt">// Sort by control frame class="type">color SORT_BY_CANV_ELEMENT_BORDER_COLOR_MOUSE_DOWN, class=class="str">"cmt">// Sort by control frame class="type">color when clicking on the control SORT_BY_CANV_ELEMENT_BORDER_COLOR_MOUSE_OVER, class=class="str">"cmt">// Sort by control frame class="type">color when hovering the mouse over the control SORT_BY_CANV_ELEMENT_AUTOSIZE, class=class="str">"cmt">// Sort by the flag of the control auto resizing depending on the content SORT_BY_CANV_ELEMENT_AUTOSIZE_MODE, class=class="str">"cmt">// Sort by the mode of the control auto resizing depending on the content class=class="str">"cmt">//--- ... SORT_BY_CANV_ELEMENT_CHECK_STATE, class=class="str">"cmt">// Sort by status of a control having a checkbox SORT_BY_CANV_ELEMENT_AUTOCHECK, class=class="str">"cmt">// Sort by auto change flag status when it is selected SORT_BY_CANV_ELEMENT_CHECK_BACKGROUND_COLOR, class=class="str">"cmt">// Sort by class="type">color of control checkbox background SORT_BY_CANV_ELEMENT_CHECK_BACKGROUND_COLOR_OPACITY, class=class="str">"cmt">// Sort by non-transparency of control checkbox background class="type">color SORT_BY_CANV_ELEMENT_CHECK_BACKGROUND_COLOR_MOUSE_DOWN, class=class="str">"cmt">// Sort by class="type">color of control checkbox background when clicking on the control SORT_BY_CANV_ELEMENT_CHECK_BACKGROUND_COLOR_MOUSE_OVER, class=class="str">"cmt">// Sort by class="type">color of control checkbox background when hovering the mouse over the control SORT_BY_CANV_ELEMENT_CHECK_FORE_COLOR, class=class="str">"cmt">// Sort by class="type">color of control checkbox frame SORT_BY_CANV_ELEMENT_CHECK_FORE_COLOR_OPACITY, class=class="str">"cmt">// Sort by non-transparency of control checkbox frame class="type">color SORT_BY_CANV_ELEMENT_CHECK_FORE_COLOR_MOUSE_DOWN, class=class="str">"cmt">// Sort by class="type">color of control checkbox frame when clicking on the control SORT_BY_CANV_ELEMENT_CHECK_FORE_COLOR_MOUSE_OVER, class=class="str">"cmt">// Sort by class="type">color of control checkbox frame when hovering the mouse over the control SORT_BY_CANV_ELEMENT_CHECK_FLAG_COLOR, class=class="str">"cmt">// Sort by class="type">color of control checkbox SORT_BY_CANV_ELEMENT_CHECK_FLAG_COLOR_OPACITY, class=class="str">"cmt">// Sort by non-transparency of control checkbox class="type">color SORT_BY_CANV_ELEMENT_CHECK_FLAG_COLOR_MOUSE_DOWN, class=class="str">"cmt">// Sort by class="type">color of control checkbox when clicking on the control SORT_BY_CANV_ELEMENT_CHECK_FLAG_COLOR_MOUSE_OVER, class=class="str">"cmt">// Sort by class="type">color of control checkbox when hovering the mouse over the control class=class="str">"cmt">//--- Sort by real properties class=class="str">"cmt">//--- Sort by class="type">class="kw">string properties SORT_BY_CANV_ELEMENT_NAME_OBJ = FIRST_CANV_ELEMENT_STR_PROP, class=class="str">"cmt">// Sort by an element object name SORT_BY_CANV_ELEMENT_NAME_RES, class=class="str">"cmt">// Sort by the graphical resource name SORT_BY_CANV_ELEMENT_TEXT, class=class="str">"cmt">// Sort by graphical element text }; class=class="str">"cmt">//+------------------------------------------------------------------+ MSG_LIB_TEXT_NOVEMBER, class=class="str">"cmt">// November MSG_LIB_TEXT_DECEMBER, class=class="str">"cmt">// December MSG_LIB_TEXT_FONT_STYLE_ITALIC, class=class="str">"cmt">// Italic MSG_LIB_TEXT_FONT_STYLE_UNDERLINE, class=class="str">"cmt">// Underline
「文本控件枚举的样式与停靠参数」
在 MT5 的图表界面库里,文本类图形对象的视觉与布局行为由一组枚举常量驱动,直接决定你在面板上看到的是什么形态。 字体风格方面,MSG_LIB_TEXT_FONT_STYLE_STRIKEOUT 表示删除线,MSG_LIB_TEXT_FONT_STYLE_NORMAL 则是常规无修饰,二者可组合进 CLabel 类对象的 FontStyle 属性。 边框与立体效果由 MSG_LIB_TEXT_FRAME_STYLE_* 控制:NONE 无框、SIMPLE 细线、FLAT 平面、BEVEL 凸雕、STAMP 凹雕;对齐用 MSG_LIB_TEXT_ALIGN_LEFT / CENTER,配合 BORDER_RAISED / SUNKEN 做按钮式浮雕。 自动尺寸有两个档:GROW 只随内容变大,GROW_SHRINK 则可双向伸缩,这对动态行情标签防遮挡很实用。 停靠模式 MSG_LIB_TEXT_DOCK_MODE_* 共 7 种,NONE 锁死坐标,TOP/BOTTOM 贴边并沿容器宽拉伸,LEFT/RIGHT 沿高拉伸,FILL 铺满,写多控件面板时优先用这些而非手算坐标。 勾选态 MSG_LIB_TEXT_CHEK_STATE_* 含未勾、已勾、未定三态,做筛选器开关时别漏掉 INDETERMINATE 的中间态。 下例是原文列出的部分常量定义,开 MT5 的 MQL5/Include/Graph 翻出同文件即可对照编译。
MSG_LIB_TEXT_FONT_STYLE_STRIKEOUT, class=class="str">"cmt">// Strikeout MSG_LIB_TEXT_FONT_STYLE_NORMAL, class=class="str">"cmt">// Normal MSG_LIB_TEXT_FRAME_STYLE_NONE, class=class="str">"cmt">// None MSG_LIB_TEXT_FRAME_STYLE_SIMPLE, class=class="str">"cmt">// Simple MSG_LIB_TEXT_FRAME_STYLE_FLAT, class=class="str">"cmt">// Flat MSG_LIB_TEXT_FRAME_STYLE_BEVEL, class=class="str">"cmt">// Embossed convex MSG_LIB_TEXT_FRAME_STYLE_STAMP, class=class="str">"cmt">// Embossed concave MSG_LIB_TEXT_ALIGN_LEFT, class=class="str">"cmt">// Left alignment MSG_LIB_TEXT_ALIGN_CENTER, class=class="str">"cmt">// Center alignment MSG_LIB_TEXT_BORDER_RAISED, class=class="str">"cmt">// Raised MSG_LIB_TEXT_BORDER_SUNKEN, class=class="str">"cmt">// Sunken MSG_LIB_TEXT_AUTO_SIZE_MODE_GROW, class=class="str">"cmt">// Increase only MSG_LIB_TEXT_AUTO_SIZE_MODE_GROW_SHRINK, class=class="str">"cmt">// Increase and decrease MSG_LIB_TEXT_DOCK_MODE_NONE, class=class="str">"cmt">// Attached to the specified coordinates, size does not change MSG_LIB_TEXT_DOCK_MODE_TOP, class=class="str">"cmt">// Attaching to the top and stretching along the container width MSG_LIB_TEXT_DOCK_MODE_BOTTOM, class=class="str">"cmt">// Attaching to the bottom and stretching along the container width MSG_LIB_TEXT_DOCK_MODE_LEFT, class=class="str">"cmt">// Attaching to the left and stretching along the container height MSG_LIB_TEXT_DOCK_MODE_RIGHT, class=class="str">"cmt">// Attaching to the right and stretching along the container height MSG_LIB_TEXT_DOCK_MODE_FILL, class=class="str">"cmt">// Stretching along the entire container width and height MSG_LIB_TEXT_CHEK_STATE_UNCHECKED, class=class="str">"cmt">// Unchecked MSG_LIB_TEXT_CHEK_STATE_CHECKED, class=class="str">"cmt">// Checked MSG_LIB_TEXT_CHEK_STATE_INDETERMINATE, class=class="str">"cmt">// Undefined MSG_LIB_TEXT_SUNDAY, class=class="str">"cmt">// Sunday MSG_LIB_TEXT_MONDAY, class=class="str">"cmt">// Monday MSG_GRAPH_ELEMENT_TYPE_WF_UNDERLAY, class=class="str">"cmt">// Underlay of the Panel WinForms control object
WinForms 控件枚举与画布元素整数属性
在 MT5 的自定义图形库里,WinForms 类控件被拆成了基类、容器和标准控件三层。MSG_GRAPH_ELEMENT_TYPE_WF_BASE 是所有 WinForms 控件的根类型,GROUPBOX、PANEL 归在容器分支下,LABEL、CHECKBOX、RADIOBUTTON、BUTTON 则属于标准控件,开发面板时必须先确认对象派生自 WF_BASE,否则会触发 MSG_PANEL_OBJECT_ERR_OBJ_MUST_BE_WFBASE。 图形对象还区分归属:MSG_GRAPH_OBJ_BELONG_PROGRAM 表示对象由 EA/指标脚本创建并管理,MSG_GRAPH_OBJ_BELONG_NO_PROGRAM 则是手动画在图上的。CPanel 在创建底层对象失败时会抛 MSG_PANEL_OBJECT_ERR_FAILED_CREATE_UNDERLAY_OBJ,这类错误在图表重载时容易出现。 画布元素的整数属性决定了控件在图上的几何与索引。从 MSG_CANV_ELEMENT_PROP_ID 到 MSG_CANV_ELEMENT_PROP_ACT_SHIFT_TOP,一共覆盖了 14 个整型字段,包含元素 ID、类型、列表序号、X/Y 坐标、宽高、右/下边界,以及活跃区相对左/上边缘的偏移量。 开 MT5 把下面枚举贴进头文件,搜 MSG_CANV_ELEMENT_PROP_ 就能看到每个属性在 CCanvas 里的实际取值逻辑,调界面布局时优先核对 COORD_X/Y 和 WIDTH/HEIGHT 是否越界。
MSG_GRAPH_ELEMENT_TYPE_WF_BASE, class=class="str">"cmt">// WinForms base control class=class="str">"cmt">//--- WinForms containers MSG_GRAPH_ELEMENT_TYPE_WF_CONTAINER, class=class="str">"cmt">// WinForms container base control MSG_GRAPH_ELEMENT_TYPE_WF_GROUPBOX, class=class="str">"cmt">// GroupBox control MSG_GRAPH_ELEMENT_TYPE_WF_PANEL, class=class="str">"cmt">// Panel control class=class="str">"cmt">//--- WinForms standard MSG_GRAPH_ELEMENT_TYPE_WF_COMMON_BASE, class=class="str">"cmt">// WinForms base standard control MSG_GRAPH_ELEMENT_TYPE_WF_LABEL, class=class="str">"cmt">// Label control MSG_GRAPH_ELEMENT_TYPE_WF_CHECKBOX, class=class="str">"cmt">// CheckBox control MSG_GRAPH_ELEMENT_TYPE_WF_RADIOBUTTON, class=class="str">"cmt">// RadioButton control MSG_GRAPH_ELEMENT_TYPE_WF_BUTTON, class=class="str">"cmt">// Button control MSG_GRAPH_OBJ_BELONG_PROGRAM, class=class="str">"cmt">// Graphical object belongs to a program MSG_GRAPH_OBJ_BELONG_NO_PROGRAM, class=class="str">"cmt">// Graphical object does not belong to a program class=class="str">"cmt">//--- CPanel MSG_PANEL_OBJECT_ERR_FAILED_CREATE_UNDERLAY_OBJ, class=class="str">"cmt">// Failed to create the underlay object MSG_PANEL_OBJECT_ERR_OBJ_MUST_BE_WFBASE, class=class="str">"cmt">// Error. The created object should be of WinForms Base type or be derived from it class=class="str">"cmt">//--- Integer properties of graphical elements MSG_CANV_ELEMENT_PROP_ID, class=class="str">"cmt">// Element ID MSG_CANV_ELEMENT_PROP_TYPE, class=class="str">"cmt">// Graphical element type MSG_CANV_ELEMENT_PROP_BELONG, class=class="str">"cmt">// Graphical element affiliation MSG_CANV_ELEMENT_PROP_NUM, class=class="str">"cmt">// Element index in the list MSG_CANV_ELEMENT_PROP_COORD_X, class=class="str">"cmt">// Element X coordinate on the chart MSG_CANV_ELEMENT_PROP_COORD_Y, class=class="str">"cmt">// Element Y coordinate on the chart MSG_CANV_ELEMENT_PROP_WIDTH, class=class="str">"cmt">// Element width MSG_CANV_ELEMENT_PROP_HEIGHT, class=class="str">"cmt">// Element height MSG_CANV_ELEMENT_PROP_RIGHT, class=class="str">"cmt">// Element right border MSG_CANV_ELEMENT_PROP_BOTTOM, class=class="str">"cmt">// Element bottom border MSG_CANV_ELEMENT_PROP_ACT_SHIFT_LEFT, class=class="str">"cmt">// Active area offset from the left edge of the element MSG_CANV_ELEMENT_PROP_ACT_SHIFT_TOP, class=class="str">"cmt">// Active area offset from the upper edge of the element
◍ 画布控件属性的交互与样式枚举
在 MT5 的 Canvas 控件库里,元素属性通过一组 MSG_CANV_ELEMENT_PROP_* 枚举值来配置,覆盖热区偏移、可移动性、交互开关与坐标边界。比如 MSG_CANV_ELEMENT_PROP_ACT_SHIFT_RIGHT 定义激活区距元素右缘的偏移,MSG_CANV_ELEMENT_PROP_COORD_ACT_X / Y 则直接给出激活区坐标,调试点阵面板时这两项最常用。 样式类属性分得极细:前景色与透明度(FORE_COLOR / FORE_COLOR_OPACITY)、背景色及按下/悬停态变色(BACKGROUND_COLOR_MOUSE_DOWN / MOUSE_OVER)都能独立设。边框也按上、下、左、右四边分别给 SIZE 与 COLOR,连点击和悬停的边框色都单独枚举,方便做高反馈度的按钮。 可移动与自动尺寸由 MOVABLE / AUTOSIZE 两对 flag 控制,IS_MOVABLE、IS_AUTOSIZE 是运行时状态读取项。外汇与贵金属图表挂这类自定义控件时,注意鼠标事件响应会增加主图重绘开销,高频 Tick 下可能掉帧,建议在 M15 以上周期做面板。
MSG_CANV_ELEMENT_PROP_ACT_SHIFT_RIGHT, class=class="str">"cmt">// Active area offset from the right edge of the element MSG_CANV_ELEMENT_PROP_ACT_SHIFT_BOTTOM, class=class="str">"cmt">// Active area offset from the bottom edge of the element MSG_CANV_ELEMENT_PROP_MOVABLE, class=class="str">"cmt">// Element moveability flag MSG_CANV_ELEMENT_PROP_IS_MOVABLE, class=class="str">"cmt">// Movable element MSG_CANV_ELEMENT_PROP_ACTIVE, class=class="str">"cmt">// Element activity flag MSG_CANV_ELEMENT_PROP_IS_ACTIVE, class=class="str">"cmt">// Element active MSG_CANV_ELEMENT_PROP_INTERACTION, class=class="str">"cmt">// Flag of interaction with the outside environment MSG_CANV_ELEMENT_PROP_COORD_ACT_X, class=class="str">"cmt">// X coordinate of the element active area MSG_CANV_ELEMENT_PROP_COORD_ACT_Y, class=class="str">"cmt">// Y coordinate of the element active area MSG_CANV_ELEMENT_PROP_ACT_RIGHT, class=class="str">"cmt">// Right border of the element active area MSG_CANV_ELEMENT_PROP_ACT_BOTTOM, class=class="str">"cmt">// Bottom border of the element active area MSG_CANV_ELEMENT_PROP_ENABLED, class=class="str">"cmt">// Element availability flag MSG_CANV_ELEMENT_PROP_FORE_COLOR, class=class="str">"cmt">// Default text class="type">color for all control objects MSG_CANV_ELEMENT_PROP_FORE_COLOR_OPACITY, class=class="str">"cmt">// Default text class="type">color opacity for all control objects MSG_CANV_ELEMENT_PROP_BACKGROUND_COLOR, class=class="str">"cmt">// Control background class="type">color MSG_CANV_ELEMENT_PROP_BACKGROUND_COLOR_OPACITY, class=class="str">"cmt">// Non-transparency of control background class="type">color MSG_CANV_ELEMENT_PROP_BACKGROUND_COLOR_MOUSE_DOWN, class=class="str">"cmt">// Control background class="type">color when clicking on the control MSG_CANV_ELEMENT_PROP_BACKGROUND_COLOR_MOUSE_OVER, class=class="str">"cmt">// Control background class="type">color when hovering the mouse over the control MSG_CANV_ELEMENT_PROP_BOLD_TYPE, class=class="str">"cmt">// Font width type MSG_CANV_ELEMENT_PROP_BORDER_STYLE, class=class="str">"cmt">// Control frame style MSG_CANV_ELEMENT_PROP_BORDER_SIZE_TOP, class=class="str">"cmt">// Control frame top size MSG_CANV_ELEMENT_PROP_BORDER_SIZE_BOTTOM, class=class="str">"cmt">// Control frame bottom size MSG_CANV_ELEMENT_PROP_BORDER_SIZE_LEFT, class=class="str">"cmt">// Control frame left size MSG_CANV_ELEMENT_PROP_BORDER_SIZE_RIGHT, class=class="str">"cmt">// Control frame right size MSG_CANV_ELEMENT_PROP_BORDER_COLOR, class=class="str">"cmt">// Control frame class="type">color MSG_CANV_ELEMENT_PROP_BORDER_COLOR_MOUSE_DOWN, class=class="str">"cmt">// Control frame class="type">color when clicking on the control MSG_CANV_ELEMENT_PROP_BORDER_COLOR_MOUSE_OVER, class=class="str">"cmt">// Control frame class="type">color when hovering the mouse over the control MSG_CANV_ELEMENT_PROP_AUTOSIZE, class=class="str">"cmt">// Flag of the element auto resizing depending on the content MSG_CANV_ELEMENT_PROP_IS_AUTOSIZE, class=class="str">"cmt">// The element automatically resizes to fit the content