Solved

CRichEditView context menu

Posted on 1998-03-21
4
380 Views
Last Modified: 2013-11-19
I also need a context menu (cut, copy, paste) for text only in a RichEditView MDI. Is there a simple way to implement this? P.S. Any tips on where I can learn about OLE?
0
Comment
Question by:midthune
  • 3
4 Comments
 
LVL 11

Accepted Solution

by:
mikeblas earned 100 total points
ID: 1317126
Just add a handler for
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1317127
Well, that was wierd.  What I meant to say was:

Just add a handler for WM_CONTEXTMENU. In that handler, create a CMenu item and call TrackPopupMenu() on it.  You should pass the frame window as the controlling window for the menu so that MFC can help you manage the choices.  So, you'd end up coding:

void CYourView::OnContextMenu(CWnd* pWnd, CPoint point)
{
   CMenu menu;
   if (menu.CreatePopupMenu())
   {
      menu.AppendMenu(MF_STRING, ID_CONTEXT_THIS, "This Choice");
      menu.AppendMenu(MF_STRING, ID_CONTEXT_THAT, "That Choice");

      CWnd* pFrame = GetParentFrame();
 
      menu.TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, pFrame, NULL);
   }
}

Then, turn around and write handlers for ID_CONTEXT_THIS and ID_CONTENT_THAT in your frame window.

Note that this code will react to the context menu key on Windows-compatible keyboards, as well as the SHIFT+F10 shortcut. But if you want something that works on right-clicks, you'll need to write a right-click handler and get to the mouse messages before the control does--'cause the edit control eats them itself.

.B ekiM

0
 

Author Comment

by:midthune
ID: 1317128
Thanks Mike, I had done just that but I didn't know that I needed to write a right click handler and I wondered why the menu key worked but not the mouse... this must be a quirk of the RichEditView( ? ) cuz Prosise's book doesn't mention this in his MDI example Paint6.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1317129
It's not a quirk of rich edit view--it applies to every view window that has a control inside it. The control gets dibs on the message.

.B ekiM
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Host to IP 7 73
Change to event 1 73
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 88
Not needed 13 55
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now