Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Controls
  New Posts New Posts RSS Feed - CMarkupTreeCtrl::SetItemText...
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CMarkupTreeCtrl::SetItemText...

 Post Reply Post Reply
Author
Message
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post 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;
}
 
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 04 September 2009 at 11:08am

Hi,

 
Call MARKUP_RELEASE(pOldElement) or XTPMarkupReleaseElement();
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.