Print Page | Close Window

CXTEditListBox And user Data

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=6795
Printed Date: 12 November 2025 at 7:37pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTEditListBox And user Data
Posted By: jimmy
Subject: CXTEditListBox And user Data
Date Posted: 04 April 2007 at 3:08am
Hello,

I use CXTEditListBox and in the ItemData i store a pointer to a struct.
i've subclass CXTEditListBox
in ON_WM_DELETEITEM_REFLECT()
 DeleteItem() i delete the struct.

But if i rename a item, the OnEndLabelEdit function call
            DWORD_PTR dwData = GetItemData(m_nIndex);
            DeleteString(m_nIndex);
            InsertString(m_nIndex, m_strItemText);
            SetItemData(m_nIndex, dwData);
But now in DeleteString the dwData will be destroy.
But SetItemData put the deleted Item pointer into the List.

Any solution to solve this problem ?

    Jimmy






Replies:
Posted By: Oleg
Date Posted: 04 April 2007 at 5:08am
Hi,
 
I think you need move this code from DELETEITEM_REFLECT to some OnDestroy.
 
Same DeleteString/InsertString used a lot in code - in OnMoveItemUp/OnMoveItemDown/OnItemBrowse etc.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: jimmy
Date Posted: 05 April 2007 at 8:00am
Is it not easyer to swap item text and item data, instead of delete insert ?

 Jimmy



Posted By: Oleg
Date Posted: 06 April 2007 at 8:43am
Hi,
 
It sounds weird, but in Windows API there is no way to set text for existed listbox item.
 
 
btw, check CustomizeDlg sample. It used
ON_LBN_XT_PREDELETEITEM(IDC_LBOX_TOOLSLIST, OnPreDeleteItem)
to delete items.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net