Solved

CRichEditView context menu

Posted on 1998-03-21
4
384 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Importing Special Characters in Dynamics GP Through Integration Manager 3 96
sameEnds challenge 3 193
conditional code and condition difference 9 87
no14 challenge 14 76
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 …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

742 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