Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to handle NM_RETURN in a dialog

Posted on 1998-04-10
2
Medium Priority
?
725 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 200 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

782 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