|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Lars Mohr
|
Aug 26, 2010 - 4:13 AM
|
Dear Support Team,
a stupid question concerning the TVN_ENDLABELEDIT notify message. Why do you send the "old text" with this message and not the edited text? in conformity with msdn: - Pointer to an structure. The item member of this structure is a structure whose hItem, lParam, and pszText members contain valid information about the item that was edited. If label editing was canceled, the pszText member of the TVITEM structure is NULL; otherwise, pszText is the address of the edited text.
void CExtTreeCtrl::OnInplaceControlComplete(
...
_data.hdr.code = TVN_ENDLABELEDIT;
_data.item.mask = TVIF_CHILDREN|TVIF_HANDLE|TVIF_PARAM|TVIF_STATE;
_data.item.hItem = hti;
GetItem( &_data.item );
strItemText = GetItemText( hti );
bool bModeNotNULL = true;
if( strItemText == LPCTSTR(strEditedText) )
{
bModeNotNULL = false;
_data.item.cchTextMax = 0;
_data.item.pszText = 0;
}
else
{
_data.item.cchTextMax = INT(strItemText.GetLength());
_data.item.pszText = strItemText.IsEmpty() ? _T("") : LPTSTR(LPCTSTR(strItemText));
_data.item.mask |= TVIF_TEXT;
} You send the strItemText (old text) not the strEditedText (edited text).
|
|
Technical Support
|
Aug 26, 2010 - 5:18 AM
|
Thank you for reporting this issue. Please update the source code for the following two methods: bool CExtTreeCtrl::CInplaceEdit::OnHookSpyKeyMsg(
MSG * pMSG
)
{
if( pMSG->hwnd == m_hWnd
&& ( GetStyle() & WS_VISIBLE ) != 0
)
{
if( pMSG->message == WM_KEYDOWN )
{
if( pMSG->wParam == VK_RETURN || pMSG->wParam == VK_ESCAPE )
{
HWND hWndParent = ::GetParent( m_hWnd );
HWND hWndOwn = m_hWnd;
if( hWndParent != NULL )
{
CString strText;
GetWindowText( strText );
if( pMSG->wParam == VK_ESCAPE )
{
m_bCancelMode = true;
((CExtTreeCtrl*)CWnd::FromHandlePermanent(hWndParent)) ->
OnInplaceControlComplete( LPCTSTR(strText), m_bEditingLabel );
}
else if( pMSG->wParam == VK_RETURN )
{
if( ! m_bResultSaved )
{
m_bResultSaved = true;
((CExtTreeCtrl*)CWnd::FromHandlePermanent(hWndParent)) ->
OnInplaceControlComplete( LPCTSTR(strText), m_bEditingLabel );
}
}
::InvalidateRect( hWndParent, NULL, FALSE );
}
if( ::IsWindow( hWndOwn ) )
DestroyWindow();
::SendMessage( hWndParent, WM_CANCELMODE, 0L, 0L );
return true;
}
}
}
return false;
}
void CExtTreeCtrl::OnInplaceControlComplete(
__EXT_MFC_SAFE_LPCTSTR strEditedText,
bool bEditingLabel
)
{
ASSERT_VALID( this );
HTREEITEM hti = GetInPlaceEditedItem();
if( hti == NULL )
return;
if( ! bEditingLabel )
{
TREEITEMINFO_t & _TII = TreeItemInfoGet( hti );
_TII.m_strEditText = LPCTSTR(strEditedText);
} // if( ! bEditingLabel )
else
{
HWND hWndParent = ::GetParent( m_hWnd );
UINT nOwnID = GetDlgCtrlID();
CExtSafeString strItemText;
TV_DISPINFO _data;
::memset( &_data, 0, sizeof(TV_DISPINFO) );
_data.hdr.hwndFrom = m_hWnd;
_data.hdr.idFrom = nOwnID;
_data.hdr.code = TVN_ENDLABELEDIT;
_data.item.mask = TVIF_CHILDREN|TVIF_HANDLE|TVIF_PARAM|TVIF_STATE;
_data.item.hItem = hti;
GetItem( &_data.item );
strItemText = GetItemText( hti );
bool bModeNotNULL = true;
if( strItemText == LPCTSTR(strEditedText) )
{
bModeNotNULL = false;
_data.item.cchTextMax = 0;
_data.item.pszText = NULL;
}
else
{
_data.item.cchTextMax = ( strEditedText != NULL ) ? INT( _tcslen(strEditedText) ) : 0;
_data.item.pszText = ( strEditedText != NULL ) ? LPTSTR(LPCTSTR(strEditedText)) : _T("");
_data.item.mask |= TVIF_TEXT;
}
if( ! ::SendMessage( hWndParent, WM_NOTIFY, WPARAM(nOwnID), LPARAM(&_data) ) != 0 )
{
if( bModeNotNULL )
return;
}
SetItemText( hti, LPCTSTR(strEditedText) );
} // else from if( ! bEditingLabel )
}
|
|