作为脚本调用菜单点击事件,但运行时的菜单名称是动态的
我在我创建的窗口中有一个数据窗口网格,并且该 DW 的一列作为其数据,具有与我创建的菜单和子菜单相同的不同菜单路径。重点是,当我双击每个 DW 行时,我想执行不同菜单路径的单击事件,该事件作为数据存储在每行中。 例如,第一行是“m_epith_frame.m_parms_su.m_poi.m_poi_ergast”,第二行是“m_appl_frame.m_1_sb.m_2_sb”等。 我知道在脚本中,我编写 m_epith_frame.m_parms_su.m_poi.m_poi_ergast.Clicked() ,它会触发此菜单项的 Clicked 事件,例如打开一个表单... 那么如何点击每一行并触发每一行的每个菜单路径的clicked事件呢? 我想这是一个动态事件调用问题,但我找不到任何解决方案..
提前致谢
I have a Datawindow Grid in a window I've created and one column of this DW has as its data, different menu paths that are the same of the menus and submenus I have created. The point is that when I double-click on every DW row, I want to execute the clicked event of the different menu path that is stored as data in each row.
For example the first row is "m_epith_frame.m_parms_su.m_poi.m_poi_ergast", the second is "m_appl_frame.m_1_sb.m_2_sb" etc.
I know that when in scripts, I write m_epith_frame.m_parms_su.m_poi.m_poi_ergast.Clicked(), it triggers the Clicked event of this menu item and for example opens a form...
So how can I click each row and trigger the clicked event for every menu path of each row?
It is, I suppose, a dynamic event call problem, but I can not find any solution..
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以递归菜单来构建菜单路径的字符串数组。同时构建一个菜单项数组,并使用与字符串相同的数组索引号将
menuitem
对象分配给该数组。不要使用 create,只需将menuitem
分配给数组即可。当有人单击一行时,在字符串数组中找到路径的索引,然后使用相同的索引在菜单项数组上触发单击事件。
菜单项数组保存指向菜单中真实菜单项的指针,因此它与单击菜单选项相同,例如您可以编码
,如果这是
m_epith_frame.m_parms_su.m_poi.m_poi_ergast
即单击了什么。You can recurse menus to build up a string array of the menu paths. At the same time build up an array of the menu items and assign the
menuitem
object to this using the same array index number as for the strings. Don't use create, just assign themenuitem
to the array.When someone clicks on a row, find the index of the path in the string array, then trigger a click event on the menu item array using the same index.
The menu item array holds pointers to the real menu items in the menu, so it's the same as clicking on the menu option, e.g you can code
and if this is
m_epith_frame.m_parms_su.m_poi.m_poi_ergast
that is what is clicked.