响应键盘的上下左右键

在PreTranslateMessage中进行响应
BOOL CNsMultiTransferDlg::PreTranslateMessage(MSG* pMsg)
{
	if(pMsg->wParam == VK_RETURN && pMsg->message == WM_KEYDOWN)
	{
		if(pMsg->hwnd == GetDlgItem(IDC_BTN_DOWNLOAD)->m_hWnd)
		{
			OnDownLoadAll();
		}
		else if(pMsg->hwnd == GetDlgItem(IDC_BTN_UPLOAD)->m_hWnd)
		{
			OnUpLoadAll();
		}
	}
	///>UI test
	if (pMsg->message == WM_KEYDOWN)
	{
		if (pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN || pMsg->wParam == VK_LEFT || pMsg->wParam == VK_RIGHT)
		{
			m_list.m_pSelectPathButton->ShowWindow(SW_HIDE);
		}
	}
	if(pMsg->message == WM_KEYUP)
	{
		POSITION pos = m_list.GetFirstSelectedItemPosition();
		if (pos)
		{
			int nRow = m_list.GetNextSelectedItem(pos);
			m_list.MoveButton(nRow, 2);
			m_list.m_pSelectPathButton->ShowWindow(SW_SHOW);
		}
	}
	///<

你可能感兴趣的:(mfc工作中用到的知识)