Solved

CRichEditView context menu

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 101
Line meaning 9 88
wordmultiple challenge 12 142
Problem to App source 6 75
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

830 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