Solved

CFormView with accelerators

Posted on 1997-04-02
6
665 Views
Last Modified: 2013-11-20
I've got a CFormView derived class with several edit controls. I want the user to be able to use Ctrl-C,Ctrl-V etc in them. I also want to use accelerators. In order to enable Copy, Paste etc, I added the code below. That code also seems to disable the accelerators. Any idea how to fix that?
BOOL CAdrEditView::PreTranslateMessage(MSG* pMsg)
{
if( pMsg->message != WM_INITDIALOG && IsDialogMessage(pMsg))
  return TRUE;
return CFormView::PreTranslateMessage(pMsg);
}
0
Comment
Question by:roar
[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
  • 2
  • 2
  • 2
6 Comments
 

Author Comment

by:roar
ID: 1300803
Adjusted points to 80
0
 

Expert Comment

by:JohnM
ID: 1300804
If i'm not mistaken, edit controls automatically pick up cut, copy, paste, etc.. without requiring a PreTranslateMessage(). Was there some other reason you added that function?

If you have access to the CD, you might want to do a search for the following article:
   Using Accelerator Keys When Modal Dialog Box Main Window

It provides some step-by-step instructions for setting up, and using an accelerator table in a modal dialog box (not necessarily as the main window. at that!).

0
 

Author Comment

by:roar
ID: 1300805
Edit controls in a CFormView does NOT automatically pick up cut, copy, paste. That's why I added the PreTranslateMessage().
I read the article, and tried to add a ::TranslateAccelerator as the first line in the PreTranslateMessage (there is no ProcessMessageFilter in a CFromView), but it didn't seem to work.
0
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!

 

Expert Comment

by:JohnM
ID: 1300806
I think that you have to add ::TranslateAccelerator() to  ProcessMessageFilter() in your C...App class.
0
 

Expert Comment

by:dvazquez
ID: 1300807
To do clipboard functions in a CFormView derived class, I just handle the OnEditCut, OnEditCopy, and OnEditPaste messages.  In them I do the following

//example
void OnEditCut()
{
  CEdit *pedit; // = GetEditCtrlWithFocus() -- you have to write this.

  if (pedit)
    pedit->Cut();
}

The above works whether you pick Edit | Cut from the menu or you do a ctrl-X.
0
 

Accepted Solution

by:
dvazquez earned 80 total points
ID: 1300808
/example
void OnEditCut()
{
<Picture>CEdit *pedit; // = GetEditCtrlWithFocus() -- you have to write this.

<Picture>if (pedit)
<Picture>pedit->Cut();
}

The above works whether you pick Edit | Cut from the menu or you do a ctrl-X.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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 this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses

630 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