Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

LN_SELECT in list box with multiple selection

24 views
Skip to first unread message

Marcel Müller

unread,
Dec 9, 2013, 4:29:50 PM12/9/13
to
I have a listbox with style LS_MULTISEL|LS_EXTENDEDSEL and get a
WM_CONTROL message with LN_SELECT. How do I examine what item recently
has been selected or deselected? The documentation says one should use
LM_QUERYSELECTION, but this does not reflect the recent changes.


Marcel

Paul Ratcliffe

unread,
Dec 9, 2013, 7:15:58 PM12/9/13
to
You have to use multiple LM_QUERYSELECTION messages to get all the
selected items. If you want to know what has changed, then you need to
store the previous list yourself and diff it with the current list.
This is probably somewhat easier in C++ (if you have an STL) than C.

nwo...@gmail.com

unread,
Apr 4, 2019, 7:38:28 PM4/4/19
to
I know that this is a very old question but I wanted to give a straight answer since one was not posted and someone might come looking for an answer...

You need to start by defining a select index, it needs to be signed...

SHORT sSelectIndex;

To find the first item selected you need to set sSelectIndex to return the first item selected...

sSelectIndex = LIT_FIRST;

Then you loop through the lmquery until sSelectIndex is equal LIT_NONE...

while ((sSelectIndex = (USHORT)(ULONG)WinSendMsg(hWndLstBox,
LM_QUERYSELECTION, MPFROMSHORT((SHORT)sSelectIndex), 0L)) != LIT_NONE)
{
CHAR szText[256];
// query list box item for text
WinSendMsg(hWndLstBox,
LM_QUERYITEMTEXT, MPFROM2SHORT(sSelectIndex, sizeof(szText)),
MPFROMP(szText));
printf(szText);

}

I hope someone finds this answer.
0 new messages