Solved

CFormView with accelerators

Posted on 1997-04-02
6
638 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Separate files macro - Errors on larger data set 18 65
substring method in java 1 96
no14 challenge 14 62
Detect file exist or not 3 128
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

914 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

14 Experts available now in Live!

Get 1:1 Help Now