Solved

What does ListCtrl take a return?

Posted on 1999-01-15
1
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: 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: 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: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Suggested Courses

734 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