 |
|
 |
hi !
firstly thanks your codes very much.
but i have something in the OCX project.
when i use this ctrl to my ocx project, there have some warnning boxes, and my header can't be clicked and used.
can you give me some advice ?
|
|
|
|
 |
|
|
 |
|
 |
I implemented the TreeList Control in our product several years ago and it ran like a champ. We've just upgraded to VS2010 and now the parent window does not seem to be getting any of the notifications (TVN_EXPANDING, etc.). Anyone else had any issues similar to that?
PXH
|
|
|
|
 |
|
 |
demo is not working buddy !!!!!!!!!!!!!
Please upload some thing that works ..........
Thanks ,
Raj.
S.V.Rajkumar
|
|
|
|
 |
|
 |
What can i do if i want to edit the item "subject"?
|
|
|
|
 |
|
 |
I found a bug in the CTLFrame::SortTree function, which leads to some sub items not being sorted under some circumstances. To fix it, all you have to do is exchange the two lines
hChild = m_tree.GetChildItem(hPa);
m_tree.SortItems(nCol, bAscending, hPa);
This way you sort the children first and then start the recursion with the child which is the first after sorting instead of the one which was first before you sorted them.
|
|
|
|
 |
|
 |
Hi
i want to insert a root element after an existing one how can i do that
|
|
|
|
 |
|
 |
The TreeList control is a standard windows control for ages.
Why reinventing the wheel ?!
|
|
|
|
 |
|
 |
Since when?
There is CListCtrl and CTreeCtrl, but no combination of the two that I've ever seen in MFC.
|
|
|
|
 |
|
 |
This article is very brilliant but I found a bug.
If this control have a item, then the image is not displayed.
So I try to find and modify. See the following code:
BOOL CNewTreeListCtrl::DeleteAllItems()
{
int count = CTreeCtrl::GetCount();
if(0 == count) return 0;
MemDeleteAllItems(GetRootItem());
BOOL m_bReturn= CTreeCtrl::DeleteAllItems();
((CTLFrame*)GetParent())->ResetScrollBar();
return m_bReturn;
}
|
|
|
|
 |
|
 |
on line 424 in the OnPaint handler there is this line:
pItem = (CTLItem *)CTreeCtrl::GetItemData(hItem);
after this line add:
if ( pItem == NULL )
break;
|
|
|
|
 |
|
 |
The bug will appear when the function DeleteAllItems was called in some circumstance.
Your solution is right.
|
|
|
|
 |
|
 |
I have added multiple row selection to this control, and thought i would share it with everyone.
In the file NewTreeListCtrl.h, add the following lines to the class CNewTreeListCtrl
private:
void ClearSelection();
BOOL SelectItems(HTREEITEM hItemFrom, HTREEITEM hItemTo);
HTREEITEM GetPrevItem( HTREEITEM hItem );
HTREEITEM GetLastItem( HTREEITEM hItem );
HTREEITEM GetNextItem( HTREEITEM hItem );
protected:
HTREEITEM m_hItemFirstSel;
then in the NewTreeListCtrl.cpp file add:
HTREEITEM CNewTreeListCtrl::GetFirstSelectedItem()
{
HTREEITEM hItem;
for ( hItem = GetRootItem(); hItem!=NULL; hItem = GetNextItem( hItem) )//, TVGN_NEXT ) )
if ( GetItemState( hItem, TVIS_SELECTED ) & TVIS_SELECTED )
return hItem;
return NULL;
}
HTREEITEM CNewTreeListCtrl::GetNextSelectedItem( HTREEITEM hItem )
{
for ( hItem = GetNextItem( hItem ); hItem!=NULL; hItem = GetNextItem( hItem ) )
if ( GetItemState( hItem, TVIS_SELECTED ) & TVIS_SELECTED )
return hItem;
return NULL;
}
HTREEITEM CNewTreeListCtrl::GetPrevSelectedItem( HTREEITEM hItem )
{
for ( hItem = GetPrevItem( hItem ); hItem!=NULL; hItem = GetPrevItem( hItem ) )
if ( GetItemState( hItem, TVIS_SELECTED ) & TVIS_SELECTED )
return hItem;
return NULL;
}
HTREEITEM CNewTreeListCtrl::GetLastItem( HTREEITEM hItem )
{
// Temporary used variable
HTREEITEM htiNext;
if( hItem == NULL ) {
// Get the last item at the top level
hItem = GetRootItem();
}
while( ItemHasChildren( hItem ) != NULL ) {
// Find the last child of hItem
htiNext = GetChildItem( hItem );
while( htiNext != NULL ) {
hItem = htiNext;
htiNext = GetNextSiblingItem( htiNext );
}
}
return hItem;
}
HTREEITEM CNewTreeListCtrl::GetNextItem( HTREEITEM hItem )
{
HTREEITEM hti = NULL;
if (ItemHasChildren(hItem))
hti = GetChildItem(hItem);
if (hti == NULL) {
while ((hti = GetNextSiblingItem(hItem)) == NULL) {
if ((hItem = GetParentItem(hItem)) == NULL)
return NULL;
}
}
return hti;
}
HTREEITEM CNewTreeListCtrl::GetPrevItem( HTREEITEM hItem )
{
HTREEITEM hti;
hti = GetPrevSiblingItem(hItem);
if( hti == NULL )
hti = GetParentItem(hItem);
else
hti = GetLastItem(hti);
return hti;
}
// SelectItems - Selects items from hItemFrom to hItemTo. Does not
// - select child item if parent is collapsed. Removes
// - selection from all other items
// hItemFrom - item to start selecting from
// hItemTo - item to end selection at.
BOOL CNewTreeListCtrl::SelectItems(HTREEITEM hItemFrom, HTREEITEM hItemTo)
{
HTREEITEM hItem = GetRootItem();
// Clear selection upto the first item
while ( hItem && hItem!=hItemFrom && hItem!=hItemTo )
{
hItem = GetNextVisibleItem( hItem );
SetItemState( hItem, 0, TVIS_SELECTED );
}
if ( !hItem )
return FALSE; // Item is not visible
SelectItem( hItemTo );
// Rearrange hItemFrom and hItemTo so that hItemFirst is at top
if( hItem == hItemTo )
{
hItemTo = hItemFrom;
hItemFrom = hItem;
}
// Go through remaining visible items
BOOL bSelect = TRUE;
while ( hItem )
{
// Select or remove selection depending on whether item
// is still within the range.
SetItemState( hItem, bSelect ? TVIS_SELECTED : 0, TVIS_SELECTED );
// Do we need to start removing items from selection
if( hItem == hItemTo )
bSelect = FALSE;
hItem = GetNextVisibleItem( hItem );
}
return TRUE;
}
void CNewTreeListCtrl::ClearSelection()
{
// This can be time consuming for very large trees
// and is called every time the user does a normal selection
// If performance is an issue, it may be better to maintain
// a list of selected items
for ( HTREEITEM hItem=GetRootItem(); hItem!=NULL; hItem=GetNextItem( hItem ) )
if ( GetItemState( hItem, TVIS_SELECTED ) & TVIS_SELECTED )
SetItemState( hItem, 0, TVIS_SELECTED );
}
Then add the OnKey handler to the class:
void CNewTreeListCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if ( (nChar==VK_UP || nChar==VK_DOWN) && GetKeyState( VK_SHIFT )&0x8000)
{
// Initialize the reference item if this is the first shift selection
if( !m_hItemFirstSel )
{
m_hItemFirstSel = GetSelectedItem();
ClearSelection();
}
// Find which item is currently selected
HTREEITEM hItemPrevSel = GetSelectedItem();
HTREEITEM hItemNext;
if ( nChar==VK_UP )
hItemNext = GetPrevVisibleItem( hItemPrevSel );
else
hItemNext = GetNextVisibleItem( hItemPrevSel );
if ( hItemNext )
{
// Determine if we need to reselect previously selected item
BOOL bReselect =
!( GetItemState( hItemNext, TVIS_SELECTED ) & TVIS_SELECTED );
// Select the next item - this will also deselect the previous item
SelectItem( hItemNext );
// Reselect the previously selected item
if ( bReselect )
SetItemState( hItemPrevSel, TVIS_SELECTED, TVIS_SELECTED );
}
return;
}
else if( nChar >= VK_SPACE )
{
m_hItemFirstSel = NULL;
ClearSelection();
}
CTreeCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
ResetVertScrollBar();
}
Finally when you come to parsing the selected rows from your dialog you can use this code.
HTREEITEM hItem = treeListCtrl_.m_tree.GetFirstSelectedItem();
if ( hItem == NULL )
return;
while ( true )
{
hItem = treeListCtrl_.m_tree.GetNextSelectedItem( hItem );
if ( hItem != NULL )
{
std::string text = treeListCtrl_.m_tree.GetItemText(hItem, 0);
}
else
break;
}
|
|
|
|
 |
|
 |
what this line means??
Layout a user-defined control inside the dialog into which the control is supposed to be intserted. In the class field type: "LANTIVTREELISTCTRL"
|
|
|
|
 |
|
 |
I am trying to use this control in a dialog so I need the control to have the sunken CLIENTEDGE look. Does anyone have a suggestion how to do this?
|
|
|
|
 |
|
 |
...but have you seen any good treeview for .NET?
_____________________________
...and justice for all
APe
|
|
|
|
 |
|
 |
There are several tree/list hybrids around, but this appears least bloated (although it could even do without the sorting, bold font et cetera), so it is fairly easy to integrate in your existing project. As I had only a couple of hours to get it to work (and I am certainly not a GUI programmer), this was my choice. Regretfully I find the code somewhat convoluted, and the design a bit awkward.
For all those programmers wanting to catch messages to/from the treectrl (and being too lazy/busy to rewrite this set of classes):
Add your catch in the form of "if (wParam == ID_TREE_LIST_CTRL)" to "CTLFrame::OnNotify".
Obtain the NMHDR ("NMHDR* pNMHeader = (NMHDR*)lParam;") and if pNMHeader->code is somewhere between & including TVN_FIRST and TVN_LAST you know you are catching a treectrl/view message.
It is likely you want to catch "TVN_GETDISPINFO". To do so OR "TVIF_IMAGE" to the flag in the "CNewTreeListCtrl::InsertItem" of your choice and set the image ID to I_IMAGECALLBACK.
Cheers..
|
|
|
|
 |
|
 |
Hello,
Are there any Copyright issues to use the this tree control?
Thanks
|
|
|
|
 |
|
 |
I prefer to using the defaul CHeadCtrl
But I got a Assert(FALSE) in CHeaderCtrl::OnDrawItem
Could anyone explain why it happen and how to solve this?
|
|
|
|
 |
|
 |
When inserting the column you have to remove the HDF_OWNERDRAW from the HDITEM struct so that the the owner draw hook is not called.
|
|
|
|
 |
|
 |
I cannot catch the TVN_BEGINLABELEDIT message (nor TVN_ENDLABELEDIT) when calling the tree's EditLabel from the parent dialog (the one that owns the CTLFrame).
The edit control displays but no message is caught by my handlers in the parent dialog:
ON_NOTIFY(TVN_BEGINLABELEDIT, IDC_TREECTRL, OnBeginlabeleditArrayDefinitionTree)
ON_NOTIFY(TVN_ENDLABELEDIT, IDC_TREECTRL, OnEndlabeleditArrayDefinitionTree)
I have also tried catching these inthe CTLFrame.
Has anyone else tried this?
>> SINCE POSTING
I have managed to catch the messages TVN_BEGINLABELEDITW and TVN_ENDLABELEDITW in the CTLFrame::OnNotify.
<< SINCE POSTING
>> SINCE POSTING 2
Adding this line just after m_tree.Create(..) has worked *in my case*.
TreeView_SetUnicodeFormat(m_tree.GetSafeHwnd(), FALSE);
I can now catch TVN_BEGINLABELEDIT etc in the OnNotify handlers.
Cool! Thanks for the help!
<< SINCE POSTING 2
|
|
|
|
 |
|
 |
:-DHow can I get this control as .NET assembly or ActiveX control?
stas-777@yandex.ru
|
|
|
|
 |
|
 |
When I change tekst in column 0 ( tree node ), old text is also visible - is mix with new text (probably in OnPaint call oryginal CTreeCtrl function)! My solution is that:
BOOL CNewTreeListCtrl::SetItemText( HTREEITEM hItem, int nCol ,LPCTSTR lpszItem )
{
CJProperty *pItem = (CJProperty *)CTreeCtrl::GetItemData(hItem);
if(!pItem)
return FALSE;
pItem->SetSubstring(nCol, lpszItem);
if( nCol == 0 )//set oryginal tree data
{
CTreeCtrl::SetItemText(hItem,lpszItem);// jk 21.1.2005
}
return CTreeCtrl::SetItemData(hItem, (LPARAM)pItem);
}
Jaromir
|
|
|
|
 |
|
 |
Has anyone tried to put the tree list control into a splitter pane?
I am having trouble and would appreciate if any one would provide a pointer.
Thanks.
|
|
|
|
 |
|
 |
Great control, but I'm using it in a front end to a database, so it needs updating pretty frequently. Apart from some memory leaks that were found by other users, I encountered frequent crashes due to access to freed-up memory locations in CNewTreeListCtrl::OnPaint(). Lacking the time to dig into it deeper, I cured it by: a) In CNewTreeListCtrl::DeleteItem, after the line delete pItem; insert the line: CTreeCtrl::SetItemData(hItem, NULL); In CNewTreeListCtrl::MemDeleteAllItems, do the same: after the line delete pItem; insert the line: CTreeCtrl::SetItemData(hItem, NULL); b) in CNewTreeListCtrl::OnPaint(), test pItem if it's a valid pointer (e.g. "if(pItem != NULL) ) before you do anything with it. This is necessary in various places throughout the body of the method, and it takes some minutes to do it, but they're well spent.
The event TVN_SELCHANGED seems to be sent twice with each change of selection. In my case, bacause I use this event to refresh part of the tree from the database, this hurt performance badly. Again lacking the time to dig into the problem any deeper, I cured it by checking the HTREEITEM that was selected against a member variable inside the handler method, and doing nothing if they are equal: void CNewTreeListCtrl::OnSelChanged( ... ) { . . . HTREEITEM hItem = GetSelectedItem(); if(hItem == m_hLastChangedItem) { return; } m_hLastChangedItem = hItem; . . . }
|
|
|
|
 |