pListCtrl->SetFocus();
pListCtrl->EditLabel(row);
In the code above, we can in_place edit the label of a listview control. But the editing only finish when you click your mouse. How can it finish when I press ENTER down?
Thanks!
Printable View
pListCtrl->SetFocus();
pListCtrl->EditLabel(row);
In the code above, we can in_place edit the label of a listview control. But the editing only finish when you click your mouse. How can it finish when I press ENTER down?
Thanks!
I think that U could use Pretranslate message
to catch ENTER key. Actually I haven't done that
for listctrl but I did such thing in treectrl.
It might work, so try and do let me know.
Here is routine that i have done in treectrl window.
BOOL CMyTreeWnd::PreTranslateMessage(MSG* pMsg)
{
if( pMsg->message == WM_KEYDOWN )
{
if( m_MyTreeCtrl.GetEditControl() &&
(pMsg->wParam == VK_RETURN ||
pMsg->wParam == VK_DELETE ||
pMsg->wParam == VK_ESCAPE ||
GetKeyState(VK_CONTROL)))
{
::TranslateMessage(pMsg);
::DispatchMessage(pMsg);
return TRUE;// DO NOT process further
}
}
return CMyTreeParentWnd::PreTranslateMessage(pMsg);
}
Hope for help. :)
Walter
Thanks for your reply very much. The concept that you say can work. I modify some of your code because the listview control is on the dialogbar. The code is as following:
BOOL CMainFrame::PreTranslateMessage(MSG *pMsg)
{
CListCtrl* pListCtrl = (CListCtrl*)m_wndDlgBar.GetDlgItem(IDC_LIST2);
if( pMsg->message == WM_KEYDOWN )
{
if( pListCtrl->GetEditControl() &&
(pMsg->wParam == VK_RETURN ||
pMsg->wParam == VK_DELETE ||
pMsg->wParam == VK_ESCAPE ||
GetKeyState(VK_CONTROL)))
{
::TranslateMessage(pMsg);
::DispatchMessage(pMsg);
return TRUE;// DO NOT process further
}
}
return CWnd::PreTranslateMessage(pMsg);
}