Solved

CFormView with accelerators

Posted on 1997-04-02
6
635 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
Comment Utility
Adjusted points to 80
0
 

Expert Comment

by:JohnM
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Expert Comment

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

Expert Comment

by:dvazquez
Comment Utility
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
Comment Utility
/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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

771 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

11 Experts available now in Live!

Get 1:1 Help Now