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

    Question Extending edit menu

    Hi,

    is there a way to extend the standard menu, that appears on right clicking an edit control, with own commands?

    Thanks,

    Winni

  2. #2
    Join Date
    Jun 2002
    Location
    Sweden
    Posts
    81
    Well I don't know an easy way, but what I would do (unless I decided to rewrite the control all together) would be to subclass the edit-windows class. I'm not talking MFC here, but that might be easier than this.
    This is how:

    Lookup SetWindowLong() and use it to change the WndProc used for the edit-control. All messages other than WM_RBUTTONUP (or whatever) you pass on to the old WndProc, which you'll get with GetWindowLong() (obviously you'll need to call that before SetWindowLong()). When you get the WM_RBUTTONUP you construct the menu. Tip: use the same id:s for the standard menu items (which you also have to construct).
    Then you need to catch WM_COMMAND as well. Check if the command comes from you "own" menu-items, if it doesn't just pass it on to the old WndProc and it will work as normal.

    I haven't tried the things about the menu, but the first part works (at least for me). Sorry if I am a bit unclear, I hope you understand what I mean.

  3. #3
    Join Date
    Aug 2001
    Location
    germany
    Posts
    772

    extending edit menu

    Hi,

    I'm not sure but you could try to handle the OnRButtonDown message yourself.
    You could create a menu which can be attached to the mouse cursor and appears when you hold right button down. If you want to try that I can tell you how to create the menu and attach it.

  4. #4
    Join Date
    Feb 2001
    Location
    Germany
    Posts
    20
    Hi,

    thanks for the replies. I think, I have to make things clearer. I´ve already subclassed the edit control and catch the WM_RBUTTONDOWN. What I want to do is, get a handle to the standard context menu and to add some additional items. Probably the only way is, to build a menu, that has all standard entries and implement the standard functionality, but I would like to avoid this.

    Thanks,

    Winni

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