Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List control problem

Status
Not open for further replies.

shteev

Programmer
Jul 15, 2003
42
0
0
I'm writing an appliction in Visual C++ 6 using a List Control. When the item highlighted in the list changes, I want a message to be sent so I know, so that I can update an Edit Box (which contains text from the highlighted member of the list). But there doesn't seem to be an appropriate message I can use. Is there? Or will I have to do this another way?
 
How about [tt]LBN_SELCHANGE[/tt]?

[sub]I REALLY hope that helps.[/sub]
Will
 
Hmm. I've been using a list view control so far in my app, using the 'report' view. LBN_SELCHANGE is generated for list boxes, but not list view controls. I'm off to experiment now to see if I can get away with using a List Box, but I'd still like to know; is there a similar message to LBN_SELCHANGE for list view controls?
 
Oh.. I didn't read carefully, sorry. you mean List View Controls, don't you.

MFC calls them List Controls to avoid confusion with CListView I think... stupid naming conventions.

Anyway, in that case, the answer is LVN_ITEMACTIVATE.

(From MSDN:)

> Remarks:

> To obtain the items being activated, the receiving
> application should use the LVM_GETSELECTEDCOUNT message
> to retrieve the number of items that are selected and
> then send the LVM_GETNEXTITEM message with LVNI_SELECTED
> until all of the items have been retrieved.


[sub]I REALLY hope that helps.[/sub]
Will
 
Cheers for that.

However, it isn't supported by the Class Wizard, and I'm not sure exactly how to put it into the code. Can you show me how I can use it to call a function?
 
you can check to see if an item is selected whenever the list is clicked. Use NM_click from the wizard. that means someone clicked in the list. you can then check to see if they selected an item by using the methods of clistctrl.
 
Thats true; but it doesn't detect when a key is used to change the selected item. I suppose I could trap that separately.

I asked a friend of mine who had the same problem; he ended up using a short timer to continually check what item was selected.

It all seems like a bit of a bodge, tho, especially if there's a message set up specifically to handle this situation. If I figure out how to use it I'll let you know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top