Solved

How to handle NM_RETURN in a dialog

Posted on 1998-04-10
2
668 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

828 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