CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2001
    Posts
    44

    Context Menu on Richtextbox

    On Richtextbox control, when I click right mouse button, default context menu will be displayed.

    Please help me that : Can I change default menu ?
    If yes, How to do that ?

    Thank you in advance.


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Context Menu on Richtextbox

    You can't change the default, but there is a workaround. In the MouseUp event of the texbox, check to see if the right button is clicked, then set the Enabled property to false, and then back to true. this way, the popup will not show up, then you can show your own.


    private Sub RichTextBox1_MouseUp(Button as Integer, Shift as Integer, x as Single, y as Single)

    If Button = 2 then
    RichTextBox1.Enabled = false
    RichTextBox1.Enabled = true
    Popupmenu mnuMyPopup
    End If

    End Sub




    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Apr 2001
    Posts
    44

    Re: Context Menu on Richtextbox

    Your idea is good. Thank you.

    But I see that the default menu still shows after my menu.



  4. #4
    Join Date
    Apr 2001
    Posts
    44

    Re: Context Menu on Richtextbox

    I found out this way :

    private Sub rtfText_MouseUp(Button as Integer, Shift as Integer, x as Single, y as Single)

    If (Button = 2) then
    rtfText.AutoVerbMenu = false
    PopupMenu mnuMyContext
    End If

    End Sub





    Please comment!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured