CMarkupTreeCtrl::SetItemText... |
Post Reply |
Author | |
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
Posted: 04 September 2009 at 9:55am |
Consider this:
HTREEITEM CMarkupTreeCtrl::AddItem(LPCTSTR lpszItem, int nImage, int nSelectedImage, HTREEITEM hParent/* = TVI_ROOT*/, HTREEITEM hInsertAfter/* = TVI_LAST*/)
{
CXTPMarkupUIElement* pUIElement = Parse(lpszItem);
...
Now I want to update the text, so I implemented SetItemText. The problem is: how do I free the memory held by the previous CXTPMarkupUIElement object? The destructor is private!
----------------------------------------------------------------------------------------
BOOL CMarkupTreeCtrl::SetItemText(HTREEITEM hItem, LPCTSTR lpszItem)
{ CXTPMarkupUIElement* pOldElement = (CXTPMarkupUIElement*)GetItemData(hItem); SetItemData(hItem, NULL); // Not sure if this is necessary? // FREE pOldElement?? BOOL retVal = FALSE;
CXTPMarkupUIElement* pUIElement = Parse(lpszItem); if (pUIElement) retVal = CXTTreeCtrl::SetItemText(hItem, GetInnerText(pUIElement)); else retVal = CXTTreeCtrl::SetItemText(hItem, lpszItem); SetItemData(hItem, (DWORD_PTR)pUIElement); return retVal; } |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi, Call MARKUP_RELEASE(pOldElement) or XTPMarkupReleaseElement();
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
Thanks!
Btw, is the call to SetItemData(NULL) dangerous or can you assume that WM_PAINT is not sent at this time?
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi, Don't think Microsoft do this, but guess you have to test it.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |