Solved

Why don't my mnemonic keys work?

Posted on 1997-08-21
6
632 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
ID: 1304481
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
ID: 1304482
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
ID: 1304483
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:corno
ID: 1304484
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
ID: 1304485
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
ID: 1304486
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

860 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