How can I change the textcolor of a specific subitem of a tree item? I have a tree list with 5 columns and one of them is called "Priority". Each priority item in this column should have a specific text color. How can I do that? How can I change the text color of a subitem? Thanks a lot. Regards Catia
ReplyHi, great control!! very useful. but when I try the demo, passing with the mouse on the grid, I see GDI objects growing in task manager ( windows XP SP2 ) davide
ReplyOriginally posted by: gabave
When i edit combo/ edit box after move the scroll bar values isn't right. This code is a solution to this bug.
void CTreeListCtrl::ShowEditComboBoxes(POINT point)
{
CDependDlg *pFrame = (CDependDlg*)GetParent();
int nMin, nMax, nPos;
if (pEdit)
{
delete pEdit;
}
if (pCombo)
{
delete pCombo;
}
//gets text of current column and row
CTLItem *pItem = (CTLItem *)CTreeCtrl::GetItemData(m_selectedItem);
if ((m_selectedItem)&&((pItem->IsEditable())||(pItem->HasCombo())))
{
DWORD dwStyle;
CTLItem *pItem=NULL;
CString csSelectedSubText="";
int nLastLeftPos=0;
POINT tempPoint=point;
tempPoint.y=3;
int nCol = m_wndHeader.GetItemCount();
pFrame->m_horScrollBar.GetScrollRange(&nMin, &nMax);
nPos = pFrame->m_horScrollBar.GetScrollPos();
CRect tree;
GetClientRect(&tree);
tempPoint.x += nPos;
for (int i=0;i<nCol;i++)
{
CRect rect(nLastLeftPos,2,GetColumnWidth(i)+nLastLeftPos,4);
if (PtInRect(rect, tempPoint))
{
pItem = (CTLItem *)CTreeCtrl::GetItemData(m_selectedItem);
// get current string in column
csSelectedSubText=pItem->GetSubstring(i);
// work out edit box size
CRect m_labelRect;
GetItemRect( m_selectedItem, &m_labelRect,TRUE );
rect.top=m_labelRect.top;
rect.bottom=rect.top+m_labelRect.Height();
// if first column then restrict label left offset and left align text
if (i==0)
{
dwStyle=ES_LEFT;
rect.right -= nPos;
if( !nPos )
rect.left=m_labelRect.left;
else
{
rect.left = 0;
rect.right = GetColumnWidth(i);
}
}
else
{
dwStyle=ES_RIGHT;
int colWidth = GetColumnWidth(i);
int colRight = abs(rect.right -= nPos);
int colLeft = abs(tree.right - nLastLeftPos + nPos);
if( colLeft < colWidth )
{
rect.right = tree.right;
rect.left = tree.right - colWidth;
}
else if( colRight < colWidth )
{
rect.left = 0;
rect.right = colWidth;
}
else
{
rect.left= nLastLeftPos - nPos;
rect.right = colRight;
}
}
if (pItem->IsEditable())
{
dwStyle|=WS_BORDER |WS_CHILD| WS_VISIBLE| ES_AUTOHSCROLL;
// create edit box
pEdit = new CTreeListEditBox(m_selectedItem, i, csSelectedSubText);
pEdit->Create(dwStyle, rect, this, 1);
}
else
{
dwStyle |= WS_CHILD |WS_TABSTOP| WS_VISIBLE| WS_VSCROLL| CBS_DROPDOWNLIST;
rect.top-=2
rect.bottom=rect.top+100;
pCombo = new CTreeListComboBox(m_selectedItem, i, csSelectedSubText);
pCombo->Create(dwStyle, rect, this, 1);
}
}
nLastLeftPos=nLastLeftPos+GetColumnWidth(i);
}
}
}
Originally posted by: gave
When i do double click on item of the list/tree control after shifted the horizontal scroll bar the label of the item isn't right. Function GetColumnsNum() in ShowEditComboBoxes() return a wrong value!
ReplyOriginally posted by: Bogdan BRINZAREA
I found out a small bug in the function that handles the
double click action. If the double click is outside the
tree area, below the tree the program generates an error.
This is because the program tries to handle the message
for a tree item that doesn't exist.
The solution is:
void CTreeListCtrl::OnLButtonDblClk(UINT nFlags, CPoint point)
{
if((GetColumnsNum()==0) || (point.x<GetColumnWidth(0)))
{
CTreeCtrl::OnLButtonDblClk(nFlags, point);
ResetVertScrollBar();
}
SetFocus();
m_selectedItem = HitTest(point, &nFlags);
//verify that there is an item selected
if(m_selectedItem!=NULL)
ShowEditComboBoxes(point);
}
Reply
Originally posted by: Cary Martin
Could you all please give these contributors a break!
They atleast took the time and effort to contribute.
the least you can do is take what they offer, and use it
it you can, if you can't just move on.
What do you have to contribute?
ReplyOriginally posted by: Purushoth
i would like to access data from database into each nodes of tree.would it be faster while rendering into browser, as thousands of nodes to be displayed to client??, would it be faster upon collapse or expand of tree for large nodes.
- Purushoth
ReplyOriginally posted by: gracias carol
hi
it looks to me that u have done good work in tree control , i am looking for adding the right click menu pop up option of shift up and shift down on the selected node of tree control. Need help on it right now my cut/copy/paste/drag/drop are working fine.
Thanks
gracias
Originally posted by: Ajay pandey
Hi,
I Need to create a full working tree outlook style using activx tree object. can anybody guide me how to do it?
thanx
Originally posted by: DIPESH
I HAVE A QUESTION THAT CAN I CHANGE THE COLOR OF EACH LIST VIEW/TREE VIEW CONTROL.
thanks
DEAR MADAM/SIR,
IF YES HOW CAN I? PLEASE REPLY ME AS EARLY AS POSSIBLE..........
regards
dipesh