Solved

How to handle NM_RETURN in a dialog

Posted on 1998-04-10
2
670 Views
Last Modified: 2013-11-20
It appears that NM_RETURN never gets sent if a list control is embedded in a dialog.  NM_DBLCLK definitely gets called, but NM_RETURN, when the focus is on an item in the list control never gets fired.  The only thing that gets fired is the default button handler.  I believe that the message never gets fired because I have tried to capture the message in pretranslate and it never captured the message.
0
Comment
Question by:falkland
2 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 50 total points
ID: 1317607
Correct, the new controls (treeview and listview) don't appear to follow correct dialog controls semantics. They are really designed to be in a window and not in a dialog. To get around this problem, you need to set the default ID to a hidden button. The hidden button will be clicked when the user presses the return key. This function can tell if the focus came from the list control (through WM_SETFOCUS), if it is, then you can do whatever you like. Otherwise, you can then simulate the Ok button being pressed.

0
 

Author Comment

by:falkland
ID: 1317608
if (GetDlgItem(IDC_LIST)==SetFocus())
  OnOK();
else
  OnSearch();

Did the trick!!  This code was placed in the bn_clicked handler for the hidden button.
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Define unique primary key 9 95
sameEnds challenge 3 187
changeXy challenge 13 93
x-bar in Google Sheets 2 93
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: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

749 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