当我从 VB6 的上下文菜单中选择一个选项时,如何阻止显示额外的上下文菜单?

发布于 2024-12-01 10:01:47 字数 1229 浏览 1 评论 0原文

我正在维护一个带有 VB6 表单的应用程序,其中包含 ComponentOne VSFlexGrid 7.0。我们有一个自定义上下文菜单,允许用户执行一些专门的复制和粘贴操作。最近,我们遇到了以下问题:

  1. 突出显示其中一个单元格中的某些文本。
  2. 右键单击单元格,文本仍突出显示。
  3. 选择上下文菜单选项之一。
  4. 发生请求的上下文菜单操作。
  5. 另一个上下文菜单类似于所示的 此处,其中包含“从右到左阅读顺序”、“打开 IME”和“重新转换”等选项。

如何使第二个上下文菜单消失?我已经尝试过 Microsoft 知识库描述 的方法,但到目前为止没有成功。我的 WindowProc 函数如下:

Function WindowProc(ByVal hw As Long, _
                    ByVal uMsg As Long, _
                    ByVal wParam As Long, _
                    ByVal lParam As Long) As Long

    Select Case uMsg
        Case WM_RBUTTONUP
            frmMain.PopupMenu frmMain.mnuPopUp
        Case Else
            WindowProc = CallWindowProc(lpPrevWndProc, hw, _
                                       uMsg, wParam, lParam)
    End Select
End Function

复制操作发生后,我看到的 uMsg 值为 15 (WM_PAINT) 和 32 (WM_SETCURSOR)。我还注意到,当我没有突出显示单元格中的文本时,表单级 MouseUp 事件会触发,但当我突出显示单元格中的文本时,它不会触发。

对 VB6 和/或 ComponentOne 有更深入了解的人能否给我更多有关事件发生顺序的详细信息,以及如何防止显示此额外的上下文菜单?

I am maintaining an application with a VB6 form that contains a ComponentOne VSFlexGrid 7.0. We have a custom context menu that allows users to perform some specialized copy-and-paste operations. Recently, we have encountered the following issue:

  1. Highlight some text in one of the cells.
  2. Right-click in the cell, with the text still highlighted.
  3. Select one of the context menu options.
  4. The requested context menu operation occurs.
  5. Another context menu similar to the one shown here, with options such as "Right to left reading order", "Open IME", and "Reconversion", is displayed.

How do I make this second context menu go away? I have tried the method that the Microsoft Knowledge Base describes with no luck so far. My WindowProc function is below:

Function WindowProc(ByVal hw As Long, _
                    ByVal uMsg As Long, _
                    ByVal wParam As Long, _
                    ByVal lParam As Long) As Long

    Select Case uMsg
        Case WM_RBUTTONUP
            frmMain.PopupMenu frmMain.mnuPopUp
        Case Else
            WindowProc = CallWindowProc(lpPrevWndProc, hw, _
                                       uMsg, wParam, lParam)
    End Select
End Function

After the copy operation happens, the uMsg values that I see are 15 (WM_PAINT) and 32 (WM_SETCURSOR). I have also noticed that a form-level MouseUp event fires when I have not highlighted text in the cell, but it does not fire when I have highlighted text in the cell.

Could someone with deeper knowledge of VB6 and/or ComponentOne please give me more details about what sequence of events takes place, and how to keep this extra context menu from showing up?

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

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

发布评论

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

评论(2

じ违心 2024-12-08 10:01:47

您应该处理 WM_CONTEXTMENU 来显示上下文菜单,而不是 WM_RBUTTONUP (因为不仅仅是右键单击可以触发它)。

You should be handling WM_CONTEXTMENU to show the context menu instead of WM_RBUTTONUP (as it's not just right click that can trigger it) .

稍尽春風 2024-12-08 10:01:47

如果用户右键单击,则在 BeforeMouseDown 事件中尝试设置 Cancel = True

In BeforeMouseDown event try setting Cancel = True if user is right clicking.

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