Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CFormView with accelerators

Posted on 1997-04-02
6
Medium Priority
?
679 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 160 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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

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: 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…
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

886 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