Print Page | Close Window

BUG: CXTTreeView on label edits

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=474
Printed Date: 30 May 2024 at 2:10pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: BUG: CXTTreeView on label edits
Posted By: Unormal
Subject: BUG: CXTTreeView on label edits
Date Posted: 24 February 2004 at 3:03pm

If you do something like the code below, inserting an item with a label, but then immediately firing on an editlabel, you can actually see the old label behind the box in which you are typing the new label, when the new label is short enough that the old text can poke out to the right.

Minor, but definitly a buglet.

 

insert.hParent = ItemID;
insert.hInsertAfter = TVI_FIRST;
insert.item.mask = TVIF_CHILDREN | TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
insert.item.cChildren = Item->Expandable;
insert.item.iImage = Item->IconIndex;
insert.item.iSelectedImage = Item->IconIndex;
insert.item.pszText = (char*)(LPCTSTR)Item->Name; // "New Profile" in the example above
insert.item.lParam = (DWORD)Item;
  
Item->ItemID = Tree.InsertItem( &insert );  
Tree.Expand( Item->ItemID, TVE_EXPAND );
Tree.EditLabel( Item->ItemID );

 




Replies:
Posted By: Unormal
Date Posted: 19 April 2004 at 2:52pm
This bug still appears in 8.70! 


Posted By: MacW
Date Posted: 11 October 2008 at 8:02am
Still the same problem in the 12.0.0

Will there ever be a fix for this, Oleg?


Posted By: Oleg
Date Posted: 13 October 2008 at 6:06am
Hi,
 
I can't reproduce it. :(


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


Posted By: MacW
Date Posted: 13 October 2008 at 2:32pm
I can reproduce it here any time:



It happens when the text displayed in the editor window is shorter than the text displayed by the label. I use GetDispInfo to display the labels with some additional dynamic information (the (3/19)), and when the user edits the label, I set the "real" text.


Posted By: MacW
Date Posted: 07 November 2008 at 10:36am
Hi, Oleg

any news on this?
I can reproduce it at will here.


Posted By: Oleg
Date Posted: 10 November 2008 at 2:09am
Hi,
Please attach sample.


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


Posted By: MacW
Date Posted: 10 November 2008 at 8:58am
Hi, Oleg

no sample needed.  Just call EditLabel() on a tree item in an CXTTreeCtrl-derived class which also uses GetDispInfo to dynamically supply the label text.

Catch the TVN_BEGINLABELEDIT and set a shorter text than the current text in the label (what the user can edit must not be the same what is displayed later in the tree).

E.g. The label currently shows "Some longer label" and in BeginEdit you set the text "Test" for the label. This produces the effect I mentioned.



Posted By: MacW
Date Posted: 07 December 2008 at 3:45am
Hi, Oleg

any news on this?
This bugs me every day.


Posted By: Oleg
Date Posted: 08 December 2008 at 5:59am

Hi,

Still waiting your sample.


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


Posted By: MacW
Date Posted: 08 December 2008 at 2:55pm
Oleg,

as I wrote, there is no need for a sample. I outlined the steps to reproduce several replies ago.


Posted By: Oleg
Date Posted: 08 December 2008 at 4:15pm
Hi,
And I wrote few replies ago that can't reproduce it.


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


Posted By: MacW
Date Posted: 09 December 2008 at 10:11am
Oleg, this is clearly a bug in your code.


I just don't have the time in this project to create sample applications for you. If you carry out the steps I mentioned the problem will show. I have lost a half day today again because of the documentation of XTP is misleading, plain wrong or just not existing. I'm working against tight timelines here.

If you attach the test app you have used trying to repro this bug I can look it over. Just catch TVN_BEGINLABELEDIT in your code and set a shorter text than currently in the edit control.



Posted By: MacW
Date Posted: 11 December 2008 at 6:58pm

void CSomeWnd::OnTvnBeginlabeledit(NMHDR *pNMHDR, LRESULT *pResult)
{
    LPNMTVDISPINFO ptv = reinterpret_cast<LPNMTVDISPINFO>(pNMHDR);
    // Do not allow by default
    *pResult = 1;

    CEdit* pedit = GetEditControl();
    if (pedit) {
        pedit->SetWindowText(_T("a"));
        *pResult = 0;
    }
}

If the text in the tree label was longer than "a" before, you will see the effect.


Posted By: Oleg
Date Posted: 12 December 2008 at 1:06am
Hi,
Do you see it with attached sample:
 
https://forum.codejock.com/uploads/20081212_010634_TreeCtrl.zip - TreeCtrl.zip


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


Posted By: MacW
Date Posted: 12 December 2008 at 11:42am
Hi, Oleg

Yes, I can repro this bug in your sample. I just added an "OnBeginEdit" and set a label text shorter than what's in the tree. See screen shot. I've also attached the two modified files.



uploads/20081212_114151_TreeCtrl_upd.zip - uploads/20081212_114151_TreeCtrl_upd.zip


Posted By: MacW
Date Posted: 09 August 2011 at 3:19am
SOLVED

If you override OnBeginLabelEdit in a class derived from XTPTreeBase you need to set the member variable m_htiEdit to the HTREEITEM of the item that is currently edited.

Codejock uses this member to determine if they paint the tree item in the normal colors or just plain white.

If the tree background color is not white the text drawn by the codejock tree control shows outside of the edit control created by the Windows tree control. If the text set in OnBeginLabelEdit is shorter than the text in the tree control.

If m_htiEdit is set to a HTREEITEM the OnPaint method in XTPTreeCtrl will not use the background color of the tree but white, which makes the extra text invisible next to the edit control.

Codejock should change the test in OnPaint to use m_pTreeCtrl->GetEditControl() to determine how to paint the tree text and not rely on the member variable m_htiEdit which is internal to Codejock and cannot be relied on.




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