?
Solved

Accelerator problem

Posted on 2003-03-19
4
Medium Priority
?
214 Views
Last Modified: 2013-11-20
I have an SDI application with a DialogBar to the right. The DialogBar contains a PropertySheet with several PropertyPages. The View contains an image. My problem is that sometimes accelerators like Ctrl+Z does not work. Often this happens after changing page on the PropertySheet. If I then click in the image the accelerators works again. What should I do to solve this?
0
Comment
Question by:P1R
[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
  • 3
4 Comments
 
LVL 30

Accepted Solution

by:
SteveGTR earned 150 total points
ID: 8166778
You might try creating a class derived from CPropertySheet and instantiating it. Within the class override the PreTranslateMessage() function and manually process accelerator requests like so:

BOOL CMyPropSheet::PreTranslateMessage(MSG* pMsg)
{
  // Enable accelerator processing
  if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
    {
    HACCEL hAccel = ((CFrameWnd*) AfxGetApp()->GetMainWnd())->GetDefaultAccelerator();

    if (hAccel && ::TranslateAccelerator(m_hWnd, hAccel, pMsg))
      return TRUE;
    }

  return CPropertySheet::PreTranslateMessage(pMsg);
}

Good Luck,
Steve
0
 

Author Comment

by:P1R
ID: 8167436
(I have already a class derived from CPropertySheet and I have overridden the PreTranslateMessage() function in order to call pToolTip->RelayEvent(pMsg);)

I tried to add the code for enabling accelerator processing as you suggested, but the result is still the same. I have also tried to add the code for enabling accelerator to the PreTranslateMessage() functions for each PropertyPage, and for the View, but still the same result. What to do next?
0
 

Author Comment

by:P1R
ID: 8172268
I have got it working now. I put the PreTranslateMessage function in the CMyPropertyPage class. Then I needed to set focus to the main window. The PreTranslateMessage function will be

BOOL CMyPropertyPage::PreTranslateMessage(MSG* pMsg)
{
     if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
     {
          CFrameWnd* mainWnd = (CFrameWnd*) AfxGetApp()->GetMainWnd();
          mainWnd->SetFocus();
          HACCEL hAccel = mainWnd->GetDefaultAccelerator();
          if(hAccel && ::TranslateAccelerator(m_hWnd, hAccel, pMsg))
               return TRUE;
     }

     return CPropertyPage::PreTranslateMessage(pMsg);
}
0
 

Author Comment

by:P1R
ID: 8172286
I happened to post this question also in the WinProg section. There I got an answer from DanRollins and I think it is fair to accept both as answers. Thanks!
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

764 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