Solved

Why don't my mnemonic keys work?

Posted on 1997-08-21
6
639 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
[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
  • 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
Technology Partners: 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!

 

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

717 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