Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - BUG: CXTTreeView on label edits
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

BUG: CXTTreeView on label edits

 Post Reply Post Reply
Author
Message
Unormal View Drop Down
Newbie
Newbie
Avatar

Joined: 12 November 2003
Location: United States
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote Unormal Quote  Post ReplyReply Direct Link To This Post Topic: BUG: CXTTreeView on label edits
    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 );

 

Back to Top
Unormal View Drop Down
Newbie
Newbie
Avatar

Joined: 12 November 2003
Location: United States
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote Unormal Quote  Post ReplyReply Direct Link To This Post Posted: 19 April 2004 at 2:52pm
This bug still appears in 8.70! 
Back to Top
MacW View Drop Down
Senior Member
Senior Member


Joined: 26 June 2007
Status: Offline
Points: 253
Post Options Post Options   Thanks (0) Thanks(0)   Quote MacW Quote  Post ReplyReply Direct Link To This Post 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?
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: 13 October 2008 at 6:06am
Hi,
 
I can't reproduce it. :(
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
MacW View Drop Down
Senior Member
Senior Member


Joined: 26 June 2007
Status: Offline
Points: 253
Post Options Post Options   Thanks (0) Thanks(0)   Quote MacW Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
MacW View Drop Down
Senior Member
Senior Member


Joined: 26 June 2007
Status: Offline
Points: 253
Post Options Post Options   Thanks (0) Thanks(0)   Quote MacW Quote  Post ReplyReply Direct Link To This Post Posted: 07 November 2008 at 10:36am
Hi, Oleg

any news on this?
I can reproduce it at will here.
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: 10 November 2008 at 2:09am
Hi,
Please attach sample.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
MacW View Drop Down
Senior Member
Senior Member


Joined: 26 June 2007
Status: Offline
Points: 253
Post Options Post Options   Thanks (0) Thanks(0)   Quote MacW Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
MacW View Drop Down
Senior Member
Senior Member


Joined: 26 June 2007
Status: Offline
Points: 253
Post Options Post Options   Thanks (0) Thanks(0)   Quote MacW Quote  Post ReplyReply Direct Link To This Post Posted: 07 December 2008 at 3:45am
Hi, Oleg

any news on this?
This bugs me every day.
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: 08 December 2008 at 5:59am

Hi,

Still waiting your sample.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
MacW View Drop Down
Senior Member
Senior Member


Joined: 26 June 2007
Status: Offline
Points: 253
Post Options Post Options   Thanks (0) Thanks(0)   Quote MacW Quote  Post ReplyReply Direct Link To This Post 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.
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: 08 December 2008 at 4:15pm
Hi,
And I wrote few replies ago that can't reproduce it.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
MacW View Drop Down
Senior Member
Senior Member


Joined: 26 June 2007
Status: Offline
Points: 253
Post Options Post Options   Thanks (0) Thanks(0)   Quote MacW Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
MacW View Drop Down
Senior Member
Senior Member


Joined: 26 June 2007
Status: Offline
Points: 253
Post Options Post Options   Thanks (0) Thanks(0)   Quote MacW Quote  Post ReplyReply Direct Link To This Post 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.
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: 12 December 2008 at 1:06am
Hi,
Do you see it with attached sample:
 
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
MacW View Drop Down
Senior Member
Senior Member


Joined: 26 June 2007
Status: Offline
Points: 253
Post Options Post Options   Thanks (0) Thanks(0)   Quote MacW Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
MacW View Drop Down
Senior Member
Senior Member


Joined: 26 June 2007
Status: Offline
Points: 253
Post Options Post Options   Thanks (0) Thanks(0)   Quote MacW Quote  Post ReplyReply Direct Link To This Post 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.

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.203 seconds.