Solved

What does ListCtrl take a return?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now