Click to See Complete Forum and Search --> : A problem in EditLabel()


xyjiang
May 14th, 1999, 12:34 PM
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!

Walter I An
May 14th, 1999, 07:37 PM
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

xyjiang
May 14th, 1999, 10:31 PM
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);
}