![]() |
CMarkupTreeCtrl::SetItemText... |
Post Reply
|
| Author | |
znakeeye
Senior Member
Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
Quote Reply
Topic: CMarkupTreeCtrl::SetItemText...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
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
Posted: 04 September 2009 at 11:08am |
|
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)
Quote Reply
Posted: 07 September 2009 at 6:26am |
|
Thanks!
Btw, is the call to SetItemData(NULL) dangerous or can you assume that WM_PAINT is not sent at this time?
|
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
Posted: 07 September 2009 at 6:38am |
|
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 |