当我从 VB6 的上下文菜单中选择一个选项时,如何阻止显示额外的上下文菜单?
我正在维护一个带有 VB6 表单的应用程序,其中包含 ComponentOne VSFlexGrid 7.0。我们有一个自定义上下文菜单,允许用户执行一些专门的复制和粘贴操作。最近,我们遇到了以下问题:
- 突出显示其中一个单元格中的某些文本。
- 右键单击单元格,文本仍突出显示。
- 选择上下文菜单选项之一。
- 发生请求的上下文菜单操作。
- 另一个上下文菜单类似于所示的 此处,其中包含“从右到左阅读顺序”、“打开 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:
- Highlight some text in one of the cells.
- Right-click in the cell, with the text still highlighted.
- Select one of the context menu options.
- The requested context menu operation occurs.
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该处理
WM_CONTEXTMENU
来显示上下文菜单,而不是WM_RBUTTONUP
(因为不仅仅是右键单击可以触发它)。You should be handling
WM_CONTEXTMENU
to show the context menu instead ofWM_RBUTTONUP
(as it's not just right click that can trigger it) .如果用户右键单击,则在
BeforeMouseDown
事件中尝试设置Cancel = True
。In
BeforeMouseDown
event try settingCancel = True
if user is right clicking.