Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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) .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top