Click here to Skip to main content
15,906,333 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am displaying a images in Clistctrl i want display images by up and down keys. I have Forward and backward key code..

What I have tried:

void MainPage::OnKeyList(NMHDR* pNMHDR, LRESULT* pResult)
{

LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR;


if (pLVKeyDow->wVKey == VK_LEFT || pLVKeyDow->wVKey == VK_RIGHT )
{

int nTotal = m_listCrl->GetItemCount();


if (nTotal == 0)
{
*pResult = 1;
return;
}


int nNewItem = -1;


if (pLVKeyDow->wVKey == VK_LEFT)//For Left Arrow Key
{
if (m_nSelectedItem > 0)
nNewItem = m_nSelectedItem - 1;
}
else // right arrow
{
if (m_nSelectedItem < nTotal-1)
nNewItem = m_nSelectedItem + 1;
}
if (nNewItem != -1)
{

m_nSelectedItem = nNewItem;

DrawSelectedImage();
}
}

// high-light the selected item
*pResult = 0;
}
Posted
Comments
Richard MacCutchan 25-Mar-16 8:19am    
Just add the code to handle the VK_UP and VK_DOWN keys. What exactly is the problem?
Rais Shaikh 26-Mar-16 0:29am    
I tried by using VK_UP and VK_DOWN but it is working as left and right arrow keys.
Rais Shaikh 26-Mar-16 0:29am    
can you please give me a demo thanks.

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