Solved

CRichEditView context menu

Posted on 1998-03-21
4
382 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 42
has22 challenge 11 95
sumHeights  challenge 17 71
Updating statistics with error notification email in SQL server 4 95
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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