Re: How To Refresh tree
- From: "Tom Serface" <tserface@xxxxxxx>
- Date: Tue, 22 Nov 2005 07:36:22 -0800
You can always use RedrawWindow() or Invalidate() to cause part or all of a
window to refresh.
Tom
"Refresh tree Properly" <Refresh tree Properly@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote in message news:4D7AF798-38FE-4130-9C4C-A93D91F9F318@xxxxxxxxxxxxxxxx
> Hi I am beginer in vc++,I am performing the drag and drop operation from
> left
> pane tree control to Right pane list control which contain Tree Item ,
> for that i use three events whose event handler
> OnBiginDrag()
> OnMouseMove()
> OnLButtonUP()
> I am showing here Item Image is dragging from left tree control to right
> List control; Its fine .
> now I am performing DataBase operation to insert drag item into Dorp
> Postion.
> and Call DeleteallItem() function
> then I call InitLeftTreeItem() fuction that extract the data from data
> base
> and Display it on Tree .
> in onLButtonUP() function after performinig database operation
> {
> DeleteAllItems();
> pWnd->m_lfList.InitLeftTreeData();
> }
> As i am calling in onInitDialog() function
> then tree displayed with inserted data in Left pane,its fine
> But When I click on tree Item it is not displaying Corrosponding Item in
> Right pane.
>
> But its OnSelectionChanged () function is Given below.
> //**************************
> NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
>
> CCJSDlg *pWnd=(CCJSDlg*)AfxGetMainWnd();
> CString strItemQry;
> char *cpItemQry;
> HTREEITEM hTree =pWnd->m_lfList.GetSelectedItem();
> if(hTree== NULL)
> return;
> // HTREEITEM hTree = pWnd->m_lfList.GetNextItem( hTree1, TVGN_CARET );
> //pNMTreeView->itemNew.hItem;//pWnd->m_lfList.GetSelectedItem();
>
> int nTpPriKey = GetTopicPrimaryKey(hTree);
> int nItemPriKey = GetItemPrimaryKey(hTree);
>
>
>
> if(nTpPriKey)
> {
>
> SQLiteTable tbTopicName = pWnd->GetTopicNameByTpID(nTpPriKey);
> int nTopID = tbTopicName.numRows();
>
> CString sss=tbTopicName.fieldValue(0);
> CString strTopName = obEncryptor.DecryptData(sss);
> SQLiteTable tbItemName = pWnd->GetItemNameByTpID(nTpPriKey);
>
> int nRows = tbItemName.numRows();
>
> pWnd->m_rtUpList.DeleteAllItems(RC_ITEM_ALL);
>
> if(nRows)
> {
>
> for(int i=0;i<nRows;i++)
> {
> tbItemName.setRow(i);
> int ItemID=atoi(tbItemName.fieldValue(0));
>
>
> strItemQry.Format("select ITEM_RATINGS,ITEM_TITLENAME,ITEM_CATEGORY from
> ITEMS where ITEM_ID = %d",ItemID );
> cpItemQry = new char[strItemQry.GetLength()+1];
> sprintf(cpItemQry ,"%s",strItemQry);
> SQLiteTable tbItems = CJSDB.getTable(cpItemQry);
> delete[] cpItemQry;
>
> CString strRating = obEncryptor.DecryptData(tbItems.fieldValue(0));
> CString strItmTitle = obEncryptor.DecryptData(tbItems.fieldValue(1));
> CString strItemKW = obEncryptor.DecryptData(tbItems.fieldValue(2));
>
>
>
> pWnd->m_rtUpList.InsertItem(i,strRating);
> pWnd->m_rtUpList.SetItemText(i,1,strItmTitle);
> pWnd->m_rtUpList.SetItemText(i,2,strTopName);
> pWnd->m_rtUpList.SetItemText(i,3,ItemID);
> pWnd->m_rtUpList.SetItemText(i,4,nTpPriKey);
> //pWnd->m_rtUpList.SetItemData(i,i);
> }
>
> UpdateWindow();
> }
>
> }
>
>
>
> //**********************************************************
> void CCJSTreeCtrl::InitLeftTreeData()
> {
>
> CJSEncryptor objEncrpt;
>
> CCJSDlg *pWnd = (CCJSDlg*)AfxGetMainWnd();
> pWnd->m_lfList.ModifyStyle(0, TVS_LINESATROOT | TVS_HASBUTTONS
> | TVS_SHOWSELALWAYS | TVS_HASLINES );//| //TVS_TRACKSELECT );
>
> /* CBitmap bmpImage;
> bmpImage.LoadBitmap(IDB_BITMAP1);
> m_cImageList.Add(&bmpImage, (COLORREF)NULL);
> bmpImage.DeleteObject();*/
>
> // main root for the tree
> hMainRoot = pWnd->m_lfList.InsertItem("Topic Category");
> AddItemInVector(0,hMainRoot,0,0);
> // HTREEITEM hMainRoot = pWnd->m_lfList.AddItem(TVI_ROOT, "Root", NULL,
> 0,0,0); ;
> pWnd->m_lfList.SetImageList(&m_cImageList, TVSIL_NORMAL);
> // AddItemInVector(0,hMainRoot,0);
>
> // displaying the data in main root
>
> // Check that how many parent tree exist uder root
> CString strTopicQry;
> char *cpTopicQry;
> strTopicQry.Format("select TOPIC_ID,TOPIC_NAME from TOPICS where
> PARENT_TOPIC_ID is NULL");
> cpTopicQry = new char[strTopicQry.GetLength()+1];
> sprintf(cpTopicQry ,"%s",strTopicQry);
> SQLiteTable tbTopicNames = CJSDB.getTable(cpTopicQry);
> delete[] cpTopicQry;
>
> // count for number of parent tree
> int nCnt=tbTopicNames.numRows();
>
> // proceed if any parent exist
>
> if(tbTopicNames.numRows())
> {
>
> for(int i=0;i<nCnt;i++)
> {
> tbTopicNames.setRow(i);
> int nTopID=atoi(tbTopicNames.fieldValue(0));
> // CString strTopicName = tbTopicNames.fieldValue(1);
> CString strTopicName=obEncryptor.DecryptData(tbTopicNames.fieldValue(1));
>
> // insert parent under root
> HTREEITEM hTopRoot = pWnd->m_lfList.InsertItem(strTopicName,hMainRoot);
> AddItemInVector(0,hTopRoot,nTopID,0);
>
> // get any child under parent
> SQLiteTable tbSbTopicNames=pWnd->GetTopicNameTbWidTpIDandPtpID(nTopID);
> int nRows=tbSbTopicNames.numRows();
>
> //proceed if any child exist
> if(tbSbTopicNames.numRows())
>
> {
> for(int i=0;i<tbSbTopicNames.numRows();i++)
>
> {
> tbSbTopicNames.setRow(i);
> int nSubTopID = atoi(tbSbTopicNames.fieldValue(0));
> // show child on tree ctrl
> //AddItem(1,h1,nSubTopID);
> CString strSubTopicName =
> obEncryptor.DecryptData(tbSbTopicNames.fieldValue(1));
> HTREEITEM hSubTopRoot =
> pWnd->m_lfList.InsertItem(strSubTopicName,hTopRoot);
>
> AddItemInVector(1,hSubTopRoot,nSubTopID,0);
>
> // get any sub Chield
> SQLiteTable
> tbsbSbTopicNames=pWnd->GetTopicNameTbWidTpIDandPtpID(nSubTopID);
>
> if(tbsbSbTopicNames.numRows())
> {
> for(int i=0;i<tbsbSbTopicNames.numRows();i++)
> {
> tbsbSbTopicNames.setRow(i);
> int nSbSubTopID = atoi(tbsbSbTopicNames.fieldValue(0));
> CString strsbSubTopicName =
> obEncryptor.DecryptData(tbsbSbTopicNames.fieldValue(1));
> // Show SubChield on Tree
> HTREEITEM hSbSubTopRoot =
> pWnd->m_lfList.InsertItem(strsbSubTopicName,hSubTopRoot);
> AddItemInVector(1,hSbSubTopRoot,nSbSubTopID,0);
>
> // check for any sub chield under sub chield
> SQLiteTable
> tbsbSbSubTopicNames=pWnd->GetTopicNameTbWidTpIDandPtpID(nSbSubTopID);
> if(tbsbSbSubTopicNames.numRows())
> {
> for(int i=0;i<tbsbSbSubTopicNames.numRows();i++)
> {
> tbsbSbSubTopicNames.setRow(i);
> int nSbSbSubTopID = atoi(tbsbSbSubTopicNames.fieldValue(0));
> CString StrSbSbTopicNames =
> obEncryptor.DecryptData(tbsbSbSubTopicNames.fieldValue(1));
> // show sub sub chield
> HTREEITEM hSbSbSubTopRoot =
> pWnd->m_lfList.InsertItem(StrSbSbTopicNames,hSbSubTopRoot);
> AddItemInVector(0,hSbSbSubTopRoot,nSbSbSubTopID,0);
> // Check for any sub sub sub item and display it
> SQLiteTable tbsbSubSubItemName =
> pWnd->GetItemNameByTpID(nSbSbSubTopID);
> if(tbsbSubSubItemName.numRows())
> {
> for(int i=0;i<tbsbSubSubItemName.numRows();i++)
> {
> tbsbSubSubItemName.setRow(i);
> int nSbSbSbItemID = atoi(tbsbSubSubItemName.fieldValue(0));
> CString
> strSbSbItemName =
> obEncryptor.DecryptData(tbsbSubSubItemName.fieldValue(1));
> HTREEITEM hSbSbSbItemRoot =
> pWnd->m_lfList.InsertItem(strSbSbItemName,hSbSbSubTopRoot);
> AddItemInVector(1,hSbSbSbItemRoot,0,nSbSbSbItemID);
> }
>
> }
>
>
> }
>
> }
> // check for item in sub sub root and display it
> SQLiteTable tbsbSubItemName = pWnd->GetItemNameByTpID(nSbSubTopID);
> if(tbsbSubItemName.numRows())
> {
> for(int i=0;i<tbsbSubItemName.numRows();i++)
> {
> tbsbSubItemName.setRow(i);
> int nSbSbItemID=atoi(tbsbSubItemName.fieldValue(0));
> CString strSbSbItemName =
> obEncryptor.DecryptData(tbsbSubItemName.fieldValue(1));
> HTREEITEM hSbSbItemRoot =
> pWnd->m_lfList.InsertItem(strSbSbItemName,hSbSubTopRoot);
> AddItemInVector(1,hSbSbItemRoot,0,nSbSbItemID);
> }
>
> }
>
> }
> }
>
> // Check for item in Sub Root and display it
> SQLiteTable tbsbItemName = pWnd->GetItemNameByTpID(nSubTopID);
> if(tbsbItemName.numRows())
> {
> for(int i=0;i<tbsbItemName.numRows();i++)
> {
> tbsbItemName.setRow(i);
> int nSubItemId = atoi(tbsbItemName.fieldValue(0));
> CString
> strSubItemName = obEncryptor.DecryptData(tbsbItemName.fieldValue(1));
> HTREEITEM hSubItemRoot =
> pWnd->m_lfList.InsertItem(strSubItemName,hSubTopRoot);
> AddItemInVector(1,hSubItemRoot,0,nSubItemId);
> }
>
> }
>
> }
>
> }
> // check for item in root and display it
> SQLiteTable tbItemName=pWnd->GetItemNameByTpID(nTopID);
> if(tbItemName.numRows())
> {
> for(int i=0;i<tbItemName.numRows();i++)
> {
> tbItemName.setRow(i);
> //CString str11=tbItemName.fieldValue(0);
> int nItemID = atoi(tbItemName.fieldValue(0));
> CString strItemName =
> obEncryptor.DecryptData(tbItemName.fieldValue(1));
> HTREEITEM hItemRoot = pWnd->m_lfList.InsertItem(strItemName,hTopRoot);
> AddItemInVector(1,hItemRoot,0,nItemID);
> }
>
> }
> pWnd->m_lfList.SetItemData(hTopRoot,i);
>
> }
> }
> pWnd->m_lfList.SetItemData(hMainRoot,0);
> }
>
> ///******************************************************
>
> Please help me.
>
>
.
- References:
- How To Refresh tree
- From: Refresh tree Properly
- How To Refresh tree
- Prev by Date: Re: Does anyone receive the the Studio 2005 via MSDN subscription?
- Next by Date: USB Memory removeable disk allocation limit
- Previous by thread: How To Refresh tree
- Next by thread: Does anyone receive the the Studio 2005 via MSDN subscription?
- Index(es):
Loading