Delphi菜单合并问题

发布于 2024-07-10 06:17:06 字数 662 浏览 6 评论 0原文

我正在尝试将两个主菜单合并在一起,但在获得子项目的正确结果时遇到问题。 我在 MenuItems 上使用 GroupIndex 属性来控制合并/插入。

Menu1(带有组索引)就像这样

  • File=10
    • 打开=11
    • 关闭=12
  • 编辑=20
    • 剪切=21
    • 粘贴=22
  • 帮助=90
    • 关于=91

Menu2是这样的

  • Edit=20
    • 清除=23
  • 小部件=30
    • Widget1=31
    • Widget2=32

我正在做的事情是

  Menu1.Merge(Menu2);

,我希望组合菜单有一个新的顶部菜单“Widgets”,并在“编辑”菜单中有一个新的“清除”命令。 “小部件”工作正常,但编辑菜单丢失了剪切和粘贴功能,这不是我想要的。

如何阻止剪切和粘贴命令消失?

I'm trying to merge two main menus together, but am having problems getting the right result with sub-items. I'm using the GroupIndex property on my MenuItems to control the merging/insertion.

Menu1 (with groupindices) is like this

  • File=10
    • Open=11
    • Close=12
  • Edit=20
    • Cut=21
    • Paste=22
  • Help=90
    • About=91

Menu2 is like this

  • Edit=20
    • Clear=23
  • Widgets=30
    • Widget1=31
    • Widget2=32

And I'm doing

  Menu1.Merge(Menu2);

I want the combined menu to have a new top menu "Widgets"and a new "Clear" command in the Edit menu. "Widgets" is working fine, but the Edit Menu has lost cut and paste, which wasn't what I wanted.

How can I stop the Cut and Paste commands from disappearing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

要走干脆点 2024-07-17 06:17:06

Delphi 中的菜单合并功能的工作方式与您期望的有点不同:它是非递归的(不幸的是!)。 这意味着当您调用 Menu1.Merge 时,Menu1 的“编辑”菜单将被 Menu2 的替换

您有两个选择:

  • 手动将“剪切”和“粘贴”添加到 Menu2。
  • 编写您自己的合并函数。

我不久前遇到了同样的问题(请参阅这个问题):

我最终得到的是
使用
工具栏2000
我所有的菜单和工具栏的包。
然后你就可以下载一个非常好的
一段代码,称为
TB2Merge,
这正是你想要的。

我猜您还可以将任何自定义编写的菜单合并代码基于 TB2Merge...

The menu merge feature in Delphi works a bit differently than what you'd expect: it's non-recursive (unfortunately!). That means that when you call Menu1.Merge, Menu1's "Edit" menu gets replaced by Menu2's.

You have two options:

  • Add "Cut" and "Paste" manually to Menu2.
  • Write your own Merge function.

I had the same problem a while ago (see this SO question):

What I eventually ended up with, is
using the
Toolbar2000
package for all my menus and toolbars.
You can then download a very nice
piece of code, called
TB2Merge,
which does exactly what you want.

You could also base any custom-written menu merge code on TB2Merge, I guess...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文