Solved

CFormView with accelerators

Posted on 1997-04-02
6
641 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
  • 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Rewrite URL With Encoded Characters 6 78
unable to delete all specified values regedit 38 390
unix example issues 18 89
Problem to App 4 79
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 …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

785 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