Click here to Skip to main content
15,906,081 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created one CXTListCtrl in LVS_ICON format so i have 20 Images in Group. I am displaying images in a row 5 images and then next line like this.

Problem is that, when i need to move focused from fifth item to sixth focus is not coming on that and it is not going further images.

What I have tried:

C++
LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR;
if (pLVKeyDow->wVKey == VK_LEFT || pLVKeyDow->wVKey == VK_RIGHT || pLVKeyDow->wVKey == VK_UP || pLVKeyDow->wVKey == VK_DOWN)
{
     switch(pLVKeyDow->wVKey)
     {
        case VK_RIGHT:
                  if (SelectedItem < Total - 1)
			NewItem = SelectedItem + 1;
		if(NewItem % 5 == 0)
		{
		   m_listCtrl->SetFocus();
	           m_listCtrl->SetItemState(NewItem,LVIS_FOCUSED|LVIS_SELECTED,LVIS_SELECTED);
	}
	break;
     }
}
Posted
Updated 13-Dec-16 22:18pm
v2
Comments
Richard MacCutchan 21-Jun-16 7:32am    
If the curent item is the last in the row, then you need to increment the row number and set the column index to zero.
Sergey Alexandrovich Kryukov 21-Jun-16 11:54am    
There is no such thing as "focusing and item". Don't confuse focusing (which is always keyboard focus) and selection.
—SA

1 solution

If you design the the list control with a windows resource template, make sure that you set "Always Show Selection" to True in the list control properties. That way you will always see the selection in focused or unfocused state. If you want to set multiple selections, set "Single Selection" to False in the list control properties. If you use a listview you have to add LVS_SHOWSELALWAYS and remove the LVS_SINGLESEL style.

I hope this helps.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900