Solved

What does ListCtrl take a return?

Posted on 1999-01-15
1
228 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need a Shell script to start a service checking the port 6 50
dog bark java program 15 94
bigDiff challenge 17 105
How to convert MFC::CString to UTF8 wchar_t* 10 201
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…

785 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