Solved

Why don't my mnemonic keys work?

Posted on 1997-08-21
6
622 Views
Last Modified: 2013-11-20
I have created an application which has modeless dialog boxes. I have defined (in the resource editor) mnemonic keys for the various controls -- for example, &Close for a pushbutton that says "Close". Right now, when the dialog box has the focus (blue title bar instead of gray), pressing the mnemonic keys has absolutely no effect. Hitting tab to move among the controls also has no effect. My application also has a mainframe menu, with mnemonic keys defined (&File so that Alt-F brings up the File menu). These work.

Is there a reason for this seeming inconsistency?
0
Comment
Question by:corno
  • 3
  • 3
6 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 50 total points
Comment Utility
If you're using MFC, then make sure CWnd::PreTranslateInput is being called. That's the function that ultimately calls ::IsDialogMessage() for the dialog. ::IsDialogMessage() is the function that translates keystrokes for a dialog to do certain things.

If you are not using MFC, then you will need to modify your message loop to use ::IsDialogMessage().

0
 

Author Comment

by:corno
Comment Utility
I am using MSVC4.2. I searched for PreTranslateInput in the Help database, and it can't find it. Apparently the function does not exist. There is something called PreTranslateMessage; is this what you mean?

0
 
LVL 15

Expert Comment

by:Tommy Hui
Comment Utility
Sorry, I was looking in VC 5.0. In Visual C++ 5.0, there are two functions: PreTranslateMessage and PreTranslateInput. In a dialog's PreTranslateMessage, it calls PreTranslateInput, so make sure your dialog's PreTranslateMessage is getting called.

0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:corno
Comment Utility
I tried overloading my Dialog box's PreTranslateMessage like so:

BOOL SysSpewSystemDlg::PreTranslateMessage(MSG* pMsg)
{
      if (IsDialogMessage(pMsg))
      return TRUE;
   else
      return CWnd::PreTranslateMessage(pMsg);
}

It still doesn't work. Am I doing something wrong?

ps. if you feel the points for this question are not enough, I will increase them. I thought it would be relatively simple to solve.

0
 
LVL 15

Expert Comment

by:Tommy Hui
Comment Utility
At this point, I would try creating another dialog, but this time keep it as simple as possible. Does it work for you then? If it does not, then the problem is not in the dialog, but rather something else in the application preventing it from working. If it does, then the problem is in your dialog class and you need to find out what is different.
0
 

Author Comment

by:corno
Comment Utility
I'm sorry. It still doesn't work. However, you provided me with some leads so I'm not going to reject this answer.

Thanks


0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

7 Experts available now in Live!

Get 1:1 Help Now