CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Posts
    34

    A problem in EditLabel()


    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!


  2. #2
    Join Date
    May 1999
    Location
    Republic of Korea
    Posts
    100

    Re: A problem in EditLabel()

    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);
    :ispatchMessage(pMsg);
    return TRUE;// DO NOT process further
    }
    }

    return CMyTreeParentWnd::PreTranslateMessage(pMsg);
    }

    Hope for help.
    Walter



  3. #3
    Join Date
    May 1999
    Posts
    34

    Re: A problem in EditLabel()

    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);
    :ispatchMessage(pMsg);
    return TRUE;// DO NOT process further
    }
    }
    return CWnd::PreTranslateMessage(pMsg);
    }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured