CListCtrl Get selection?
-
Ive gone quite crazy at microsoft for the weirdness of the CListCtrl, I just want to find out the contents of the selection in my list.. I can only find this:
short Selected = m_MyList.GetSelectionMark();
But that returns the number of the item, if i fill my list with "Linux" and "Windows" then i would like a method which returns "Windows", or "Linux"... Are there any functions for that?? Thanks! (Using VS6.0 dialog based mfc app...)//Johannes
-
Ive gone quite crazy at microsoft for the weirdness of the CListCtrl, I just want to find out the contents of the selection in my list.. I can only find this:
short Selected = m_MyList.GetSelectionMark();
But that returns the number of the item, if i fill my list with "Linux" and "Windows" then i would like a method which returns "Windows", or "Linux"... Are there any functions for that?? Thanks! (Using VS6.0 dialog based mfc app...)//Johannes
Try:
CString sText;
int nSel;
nSel = m_MyList.GetSelectionMark();
if (sel != -1)
{
sText = m_MyList.GetItemText(nSel, 0);
}:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
Try:
CString sText;
int nSel;
nSel = m_MyList.GetSelectionMark();
if (sel != -1)
{
sText = m_MyList.GetItemText(nSel, 0);
}:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
Thanks, that works great :) My other problem with my CListCtrl is kind of weird... I use NM_CLICK and LVN_KEYDOWN messages, when i use the arrow keys and navigate to the end of the list contents, and try to keep going (ie at the end push down arrow a few more times) i seem to get an offset with 1 (when i go back up), same happens when i go upwards... I think the reason for this is that the LVN_KEYDOWN is not the message i want, as it seems to be called before the selection mark has changed, which message do i want? :^) Thanks :-D
//Johannes
-
Thanks, that works great :) My other problem with my CListCtrl is kind of weird... I use NM_CLICK and LVN_KEYDOWN messages, when i use the arrow keys and navigate to the end of the list contents, and try to keep going (ie at the end push down arrow a few more times) i seem to get an offset with 1 (when i go back up), same happens when i go upwards... I think the reason for this is that the LVN_KEYDOWN is not the message i want, as it seems to be called before the selection mark has changed, which message do i want? :^) Thanks :-D
//Johannes
Can't you check if actual item is different of first / last item before moving?
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
-
Ive gone quite crazy at microsoft for the weirdness of the CListCtrl, I just want to find out the contents of the selection in my list.. I can only find this:
short Selected = m_MyList.GetSelectionMark();
But that returns the number of the item, if i fill my list with "Linux" and "Windows" then i would like a method which returns "Windows", or "Linux"... Are there any functions for that?? Thanks! (Using VS6.0 dialog based mfc app...)//Johannes
Johpoke wrote:
short Selected = m_MyList.GetSelectionMark();
Are you using a multiselect list control?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne