|
|
Comments and Discussions
|
|
 |

|
I change the code so it work on Unicode chars.
And I have just one problem in the function LoadTreeFromFile( const char *pszFileName, CTreeType &tt)
I am having problems with the C fread function...
fread(pnt->buf, pnt->wBufSize, sizeof(char), fp);
a change to fread(pnt->buf, pnt->wBufSize*sizeof(TCHAR), sizeof(TCHAR), fp);
and it does not work....
Does anyone has this problem?
Mauricio Alfaro
|
|
|
|

|
/*This function can work on Unicode chars.*/
/**************************************************************************************
Load tree from a TRE file.
If the tree was successfully read, a CTreeType structure is allocated, containing
the tree.
return true if successful
**************************************************************************************/
BOOL CEditTreeCtrl::LoadTreeFromFile(const TCHAR *pszFileName, CTreeType &tt)
{
FILE *fp;
CString str;
WORD wTotalNbItems;
int iCount;
BOOL rc = true;
NODE_TYPE *pnt;
fp = _tfopen(pszFileName, _T("rb"));
if (fp == NULL)
throw TTE_OPEN;
if (fread(&wTotalNbItems, 1, sizeof(WORD), fp) == 0)
throw TTE_EMPTY_FILE;
if (wTotalNbItems == 0)
throw TTE_EMPTY_FILE;
if (!tt.AllocateTree(wTotalNbItems))
throw TTE_MEMORY;
for (iCount = 0; iCount <= wTotalNbItems; iCount++)
{
pnt = &tt.m_pnt[iCount];
fread(&pnt->wNbItems, 1, sizeof(pnt->wNbItems), fp);
if (feof(fp))
throw TTE_INVALID_FILE; // Unexpected end of file
if (ferror(fp))
throw TTE_READ;
fread(&pnt->wBufSize, 1, sizeof(pnt->wBufSize), fp);
if (feof(fp))
throw TTE_INVALID_FILE; // Unexpected end of file
if (ferror(fp))
throw TTE_READ;
if (pnt->wBufSize > 0)
{
pnt->buf = new TCHAR[pnt->wBufSize + 1];
if (pnt->buf == NULL)
throw TTE_MEMORY;
fread(pnt->buf, pnt->wBufSize, sizeof(TCHAR), fp);
pnt->buf[pnt->wBufSize] = 0;
if (feof(fp))
throw TTE_INVALID_FILE; // Unexpected end of file
if (ferror(fp))
throw TTE_READ;
}
fread(&pnt->uState, 1, sizeof(pnt->uState), fp);
if (ferror(fp))
throw TTE_READ;
}
fclose(fp);
if (feof(fp))
throw TTE_CLOSE;
tt.m_wTotalNbItems = wTotalNbItems;
return true;
}
|
|
|
|

|
I Test ypur project in a MDI project and works good, but in the edit menu with the instructions copy i get this debug...
_AFXCMN_INLINE Bool CTreeCtrl::GetCount() const....
ASSERT (::IsWindow(m_hWnd))
It´s weard because I don´t see the reason of this bug... The code seems to be right.
Do you know why this is happening?
Mauricio Alfaro
|
|
|
|

|
VS2003 SP1 - When click on tree item, all view scrolls down.
To fix this bug change strings:
From:
// Timer function to handle scrolling while dragging.
void CEditTreeCtrl::OnTimer(UINT nIDEvent)
{
if (nIDEvent == TVHT_ABOVE )
SendMessage(WM_VSCROLL, SB_LINEUP, NULL);
else
SendMessage(WM_VSCROLL, SB_LINEDOWN, NULL);
CTreeCtrl::OnTimer(nIDEvent);
}
To:
// Timer function to handle scrolling while dragging.
void CEditTreeCtrl::OnTimer(UINT nIDEvent)
{
if (nIDEvent == TVHT_ABOVE )
SendMessage(WM_VSCROLL, SB_LINEUP, NULL);
if (nIDEvent == TVHT_BELOW )
SendMessage(WM_VSCROLL, SB_LINEDOWN, NULL);
CTreeCtrl::OnTimer(nIDEvent);
}
|
|
|
|

|
Hello,
I have tested the debug version and find that shortkey CTRL+A that should copy above does not work.
A debug Assertion is reported when tryng to call EnsureVisible(hti)
hti has no object.
BOOL CEditTreeCtrl::SelectVisibleItem(HTREEITEM hti)
{
EnsureVisible(hti);
return SelectItem(hti);
}
|
|
|
|

|
Good job, great class, - but it can be much better if CTreeControl functionality be at one class (for reusability) and Load-Data functionallity at other, what do you think?
|
|
|
|

|
first thanks author's work ,he brings us neat code.
but in os 2000 server+.net 2003+debug ,there is a fixed bug .
HTREEITEM CEditTreeCtrl::SelectDropCursor(CPoint *pPoint /*= NULL*/)
{
HCURSOR hOldCursor = m_hCursor;
UINT uFlags;//<<----------look here.modify it like this
UINT uFlags=0;//initialization for it.
|
|
|
|

|
I have used your TreeEditor and I must say, well done.
I have used it to sketch out possible layouts for a fairly complex tree control we use for our product. Changing between many different layouts programatically is not much fun, so this is a welcome tool.
The only problem I found is that all the icons are identical. Would it be possible for you to add a "pool" of say 8 icons (of different shapes/colours) from which the user can allocate to a particular node on the tree. eg. right click and select icon type. This would make it easier to visually identify node types.
|
|
|
|

|
Great tools. Thanks indeed. Is it possible to print trees?
|
|
|
|

|
Hi,
Tree Editor is wonderful!
I have only one question:
Is it possible add multi-column features to Tree Editor?
Thanks!
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A fully-editable Tree Editor
| Type | Article |
| Licence | |
| First Posted | 9 Dec 2003 |
| Views | 181,233 |
| Bookmarked | 100 times |
|
|