Solved

What does ListCtrl take a return?

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 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

9 Experts available now in Live!

Get 1:1 Help Now