Solved

CRichEditView context menu

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

911 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

17 Experts available now in Live!

Get 1:1 Help Now