How do I stop an extra context menu from showing up when I select an option from a context menu in VB6?
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 ce开发者_Go百科lls.
- 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?
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) .
In BeforeMouseDown
event try setting Cancel = True
if user is right clicking.
精彩评论