Solved

What does ListCtrl take a return?

Posted on 1999-01-15
1
229 Views
Last Modified: 2013-11-20
I am using a ListCtrl, and if an item is selected and the user has pressed "Enter" (or carriage-return). Then my program should do something?
But I don't know how to do this, so could you please assist me?
Thanks in advance.
0
Comment
Question by:e1
1 Comment
 
LVL 8

Accepted Solution

by:
Answers2000 earned 100 total points
ID: 1327733
Provided the control has the focus, you will get an NM_RETURN notification message (sent in the form of a WM_NOTIFY message) whenever the user presses return

Use the class wizard to add a handler for NM_RETURN Message.

In the handler test what (if any) item(s) are selected using GetNextItem member of CListCtrl.  

// example find first selected item
int index = GetNextItem( -1, LVNI_SELECTED ) ;

index then is -1 (nothing selected) or index of first item selected.  If you list control allows more than 1 item to be selected, repeatedly call GetNextItem with the previous value of index to get the 2nd item, 3rd item etc until you get -1 back indicating no more items are selected.

Then do whatever you want with these items.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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: 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: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

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