CTreeCtrl Speeding issue
-
:rose: Hi Friends, I've a treectrl on a dialog based application which gets populated from ms-access database containing some 2000 records in OnInItDialog. To fetch the data, i am simply using the SQLFetch and inserting it using a while loop in treectrl using InsertItem, but it takes too much of time. Can anybody help me in speeding up my treectrl. The fields in my database are "BookmarkName", "BookmarkType" where Bookmark name is the bookmark name and BookmarkType is either "Folder" or "Bookmark" and Bookmarks are added as child in Folders. Vikram Kashyap "You will never fail, until u stop trying"
-
:rose: Hi Friends, I've a treectrl on a dialog based application which gets populated from ms-access database containing some 2000 records in OnInItDialog. To fetch the data, i am simply using the SQLFetch and inserting it using a while loop in treectrl using InsertItem, but it takes too much of time. Can anybody help me in speeding up my treectrl. The fields in my database are "BookmarkName", "BookmarkType" where Bookmark name is the bookmark name and BookmarkType is either "Folder" or "Bookmark" and Bookmarks are added as child in Folders. Vikram Kashyap "You will never fail, until u stop trying"
you should probably post a snippet of what your routine to insert the items into your tree control looks like. That'll make it easier for us to see where you might have any problems Who are all these people and what are they doing in my house?...Me in 30 years, inside a grocery store My articles[^] bdiamond :zzz:
-
:rose: Hi Friends, I've a treectrl on a dialog based application which gets populated from ms-access database containing some 2000 records in OnInItDialog. To fetch the data, i am simply using the SQLFetch and inserting it using a while loop in treectrl using InsertItem, but it takes too much of time. Can anybody help me in speeding up my treectrl. The fields in my database are "BookmarkName", "BookmarkType" where Bookmark name is the bookmark name and BookmarkType is either "Folder" or "Bookmark" and Bookmarks are added as child in Folders. Vikram Kashyap "You will never fail, until u stop trying"
Well, the database fetching data could be slow. Another could be the tree control. To get the tree to fill faster you can turn off the visual update of the control during the fill. Lookup SetRedraw or WM_SETREDRAW on MSDN or your help. -- Joel Lucsy
-
you should probably post a snippet of what your routine to insert the items into your tree control looks like. That'll make it easier for us to see where you might have any problems Who are all these people and what are they doing in my house?...Me in 30 years, inside a grocery store My articles[^] bdiamond :zzz:
Hi, the code snippet... void CInsertBookmark::LoadTreeItems() { BeginWaitCursor(); m_pTree.SetRedraw(FALSE); //Works fine in case of lesser records CString BookMarkType, BookMarkPath, BookMarkName; BookMarkType.Empty(); BookMarkPath.Empty(); BookMarkName.Empty(); CString TempPath; TempPath.Empty(); HSTMT hstmt; SDWORD len = SQL_NTS; RETCODE rc; char m_BookMark_Node_Path[256]; char m_BookMark_Node_Name[256]; char m_BookMark_Type[256]; int nIndex = 0; strTemp.Format("SELECT BookMark_Node_Path, " "BookMark_Node_Name, " "BookMark_Type " "FROM BookMark " "ORDER BY BookMark_Node_Path"); SQLAllocStmt(m_pdb->m_hdbc , &hstmt); SQLBindCol(hstmt,1, SQL_C_CHAR, &m_BookMark_Node_Path , sizeof(m_BookMark_Node_Path), &len); SQLBindCol(hstmt,2, SQL_C_CHAR, &m_BookMark_Node_Name , sizeof(m_BookMark_Node_Name), &len); SQLBindCol(hstmt,3, SQL_C_CHAR, &m_BookMark_Type , sizeof(m_BookMark_Type) , &len); if (SQLExecDirect(hstmt, (UCHAR*)(LPCTSTR)strTemp, SQL_NTS) == SQL_ERROR) { DisplayErrorMsg(&hstmt); SQLFreeStmt (hstmt, SQL_DROP); return ; } while(TRUE) { rc = SQLFetch(hstmt); if(rc == SQL_ERROR) { DisplayErrorMsg(&hstmt); SQLFreeStmt (hstmt, SQL_DROP); return ; } else if(rc == SQL_NO_DATA_FOUND) break; BookMarkPath.Empty(); BookMarkPath.Format("%s",m_BookMark_Node_Path); BookMarkType.Empty(); BookMarkType.Format("%s",m_BookMark_Type); BookMarkName.Empty(); BookMarkName.Format("%s",m_BookMark_Node_Name); if(BookMarkType.CompareNoCase("Folder") == 0) { m_pTree.Initialize(true); HTREEITEM hItem = m_pTree.GetNext(); while (hItem != NULL) { m_pTree.SelectItem(hItem); TempPath = GetPathFromItem(hItem) ; if(TempPath.Compare(BookMarkPath) == 0) { //Inserting items into tree ctrl m_pTree.InsertItem(_T(BookMarkName), ILI_CLSDFLD, ILI_OPENFLD, hItem, TVI_SORT); BookMarkPath.Empty(); BookMarkType.Empty(); break; } else hItem= m_pTree.GetNext(); } } if(BookMarkType.CompareNoCase("BookMark") == 0) { m_pTree.Initialize(true); HTREEITEM hItem= m_pTree.GetNext(); while (hItem != NULL) { m_pTree.SelectItem(hItem); TempPath = GetPathFromItem(hItem); if( TempPath.Compare(BookMarkPath) == 0) { //Inserting items into tree ctrl m_pTree.InsertItem(