void CShaderLibView::OnContextMenu(CWnd* pWnd, CPoint point) { CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndShaderLibView; ASSERT_VALID(pWndTree); if (pWnd != pWndTree) { CWnd::OnContextMenu(pWnd, point); return; } if (point != CPoint(-1, -1)) { // Select clicked item: CPoint ptTree = point; pWndTree->ScreenToClient(&ptTree); UINT flags = 0; HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); if (hTreeItem != NULL) { pWndTree->SelectItem(hTreeItem); } } pWndTree->SetFocus(); ( (CWinAppEx*)AfxGetApp())->GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EXPLORER, point.x, point.y, this, TRUE); }
BOOL CMainFrame::GetMyRegLeftPath(HTREEITEM hItem,char *Path) { CTreeCtrl * pList = &pRegTreeView->GetTreeCtrl(); if(hItem == NULL || hItem == pList->GetRootItem()) return FALSE; char m_ItemName[512] = {0}; char m_KeyName[2048] = {0}; char m_TmpName[2048] = {0}; HTREEITEM hCurItem = hItem; HTREEITEM hParent = NULL; while(1) { wsprintf(m_ItemName,"%s\\",pList->GetItemText(hCurItem)); sprintf(m_TmpName,"%s%s",m_ItemName,m_KeyName); strcpy(m_KeyName,m_TmpName); hCurItem = pList->GetParentItem(hCurItem); if(hCurItem == pList->GetRootItem()) break; } memcpy(Path,m_KeyName,strlen(m_KeyName)); Path[strlen(m_KeyName)] = 0; return TRUE; }
BOOL RenameVolumeDialog::OnInitDialog(void) { /* do the DoDataExchange stuff */ CDialog::OnInitDialog(); CTreeCtrl* pTree = (CTreeCtrl*) GetDlgItem(IDC_RENAMEVOL_TREE); DiskImgLib::DiskFS* pDiskFS = fpArchive->GetDiskFS(); ASSERT(pTree != NULL); fDiskFSTree.fIncludeSubdirs = false; fDiskFSTree.fExpandDepth = -1; if (!fDiskFSTree.BuildTree(pDiskFS, pTree)) { LOGI("Tree load failed!"); OnCancel(); } int count = pTree->GetCount(); LOGI("ChooseAddTargetDialog tree has %d items", count); /* select the default text and set the focus */ CEdit* pEdit = (CEdit*) GetDlgItem(IDC_RENAMEVOL_NEW); ASSERT(pEdit != NULL); pEdit->SetSel(0, -1); pEdit->SetFocus(); return FALSE; // we set the focus }
// @pymethod (int, int)|PyCTreeCtrl|HitTest|Determines which tree view item, if any, is at a specified position. PyObject *PyCTreeCtrl_HitTest( PyObject *self, PyObject *args ) { CTreeCtrl *pList = GetTreeCtrl(self); if (!pList) return NULL; TVHITTESTINFO i; memset(&i, 0, sizeof(i)); // @pyparm point|x,y||The point to test. if (!PyArg_ParseTuple( args, "(ii):HitTest", &i.pt.x, &i.pt.y)) return NULL; GUI_BGN_SAVE; pList->HitTest( &i ); GUI_END_SAVE; return Py_BuildValue("iN", i.flags, PyWinLong_FromHANDLE(i.hItem)); // @rdesc The result is a tuple of (flags, hItem). // flags may be a combination of the following values: // @flagh Value|Description // @flag commctrl.TVHT_ABOVE|Above the client area. // @flag commctrl.TVHT_BELOW|Below the client area. // @flag commctrl.TVHT_NOWHERE|In the client area, but below the last item. // @flag commctrl.TVHT_ONITEM|On the bitmap or label associated with an item. // @flag commctrl.TVHT_ONITEMBUTTON|On the button associated with an item. // @flag commctrl.TVHT_ONITEMICON|On the bitmap associated with an item. // @flag commctrl.TVHT_ONITEMINDENT|In the indentation associated with an item. // @flag commctrl.TVHT_ONITEMLABEL|On the label (string) associated with an item. // @flag commctrl.TVHT_ONITEMRIGHT|In the area to the right of an item. // @flag commctrl.TVHT_ONITEMSTATEICON|On the state icon for a tree view item that is in a user-defined state. // @flag commctrl.TVHT_TOLEFT|To the left of the client area. // @flag commctrl.TVHT_TORIGHT|To the right of the client area. }
void CMainFrame::OnRegRightFlush() { CTreeCtrl * pList = &pRegTreeView->GetTreeCtrl(); HTREEITEM hItem = pList->GetSelectedItem(); if(hItem == NULL) return; PostMessage(WM_REGLEFTDBCLICK,(WPARAM) hItem,NULL); }
// @pymethod int|PyCTreeCtrl|SetItemText|Changes the text of a list view item or subitem. PyObject *PyCTreeCtrl_SetItemText( PyObject *self, PyObject *args ) { CTreeCtrl *pList = GetTreeCtrl(self); if (!pList) return NULL; PyObject *obItem; TCHAR *text; PyObject *obtext; if (!PyArg_ParseTuple( args, "OO:SetItemText", &obItem, // @pyparm HTREEITEM|item||The item whose text is to be retrieved. &obtext)) // @pyparm string|text||String that contains the new item text. return NULL; HTREEITEM item; if (!PyWinObject_AsHANDLE(obItem, (HANDLE *)&item)) return NULL; if (!PyWinObject_AsTCHAR(obtext, &text, FALSE)) return NULL; GUI_BGN_SAVE; BOOL ok = pList->SetItemText(item, text); GUI_END_SAVE; PyWinObject_FreeTCHAR(text); if (!ok) RETURN_ERR("SetItemText failed"); RETURN_NONE; }
// @pymethod |PyCTreeCtrl|CreateWindow|Creates the actual window for the object. static PyObject * PyCTreeCtrl_CreateWindow(PyObject *self, PyObject *args) { extern CWnd *GetWndPtrFromParam(PyObject *ob, ui_type_CObject &type); CTreeCtrl *pT = GetTreeCtrl(self, false); if (!pT) return NULL; RECT rect; PyObject *obParent; long style; long id; if(!PyArg_ParseTuple(args, "l(iiii)Ol:Create", &style, // @pyparm int|style||The window style &rect.left, &rect.top, &rect.right,&rect.bottom, // @pyparm int, int, int, int|rect||The default rectangle &obParent, // @pyparm parent|<o PyCWnd>||The parent window &id))// @pyparm int|id||The control ID return NULL; CWnd *pParent = NULL; if (obParent != Py_None) { pParent = GetWndPtrFromParam(obParent, PyCWnd::type); if (pParent==NULL) return NULL; } GUI_BGN_SAVE; // @pyseemfc CTreeCtrl|Create BOOL ok = pT->Create(style, rect, pParent, id); GUI_END_SAVE; if (!ok) RETURN_ERR("CTreeCtrl::Create failed"); RETURN_NONE; }
// @pymethod <o TV_ITEM>|PyCTreeCtrl|GetItem|Retrieves the details of an items attributes. PyObject *PyCTreeCtrl_GetItem( PyObject *self, PyObject *args ) { PyObject *obItem; UINT mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_STATE | TVIF_TEXT; if (!PyArg_ParseTuple( args, "O|i:GetItem", &obItem, // @pyparm HTREEITEM|item||The item whose attributes are to be retrieved. &mask)) // @pyparm int|mask|(all flags set)|The requested attributes. return NULL; CTreeCtrl *pList = GetTreeCtrl(self); if (!pList) return NULL; HTREEITEM item; if (!PyWinObject_AsHANDLE(obItem, (HANDLE *)&item)) return NULL; TCHAR textBuf[256]; TV_ITEM tvItem; tvItem.hItem = item; tvItem.pszText = textBuf; tvItem.cchTextMax = sizeof(textBuf)/sizeof(TCHAR); tvItem.mask = mask; GUI_BGN_SAVE; BOOL ok = pList->GetItem( &tvItem); GUI_END_SAVE; if (!ok) RETURN_ERR("GetItem failed"); return PyWinObject_FromTV_ITEM(&tvItem); }
void CFileView::OnContextMenu(CWnd* pWnd, CPoint point) { CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndFileView; ASSERT_VALID(pWndTree); if (pWnd != pWndTree) { CDockablePane::OnContextMenu(pWnd, point); return; } if (point != CPoint(-1, -1)) { // 选择已单击的项: CPoint ptTree = point; pWndTree->ScreenToClient(&ptTree); UINT flags = 0; HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); if (hTreeItem != NULL) { pWndTree->SelectItem(hTreeItem); } } pWndTree->SetFocus(); theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EXPLORER, point.x, point.y, this, TRUE); }
//************************************************************************************* void CFavoritesManager::FillTree (CTreeCtrl& wndTree) { ASSERT (wndTree.GetSafeHwnd () != NULL); wndTree.DeleteAllItems (); wndTree.SetImageList (CImageList::FromHandle (m_himSystem), TVSIL_NORMAL); m_Root.FillTree (wndTree, NULL); }
// @pymethod <o PyCToolTopCtrl>|PyCTreeCtrl|GetToolTips|Returns the tooltip control PyObject *PyCTreeCtrl_GetToolTips( PyObject *self, PyObject *args ) { CTreeCtrl *pList = GetTreeCtrl(self); if (!pList) return NULL; CHECK_NO_ARGS2(args,"GetToolTips"); CToolTipCtrl*ret = pList->GetToolTips(); return ui_assoc_object::make( PyCToolTipCtrl::type, ret)->GetGoodRet(); }
void TreeDlg::OnButtonExpandAll() { CTreeCtrl *ctrl = getTreeCtrl(); int hp = ctrl->GetScrollPos(SB_HORZ); int vp = ctrl->GetScrollPos(SB_VERT); TreeItemExpander(true).visitAllItems(ctrl); ctrl->SetFocus(); ctrl->SetScrollPos(SB_HORZ, hp); ctrl->SetScrollPos(SB_VERT, vp); }
void CSiteView::OnAddRecorder() { CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndSiteView; HTREEITEM hTreeItem = pWndTree->GetSelectedItem(); SITE_T * site = (SITE_T*)pWndTree->GetItemData(hTreeItem); RecorderDlg dlg(site->uuid); dlg.DoModal(); FillSiteView(); }
void TreeDlg::OnExpandOrCollapse() { CTreeCtrl *ctrl = getTreeCtrl(); HTREEITEM item = ctrl->GetSelectedItem(); UINT state; if((state = ctrl->GetItemState(item, TVIS_EXPANDED)) & TVIS_EXPANDED) { OnCollapse(); } else { OnExpand(); } }
CTreeItem* CdIpmDoc::GetSelectedTreeItem() { CTreeCtrl* pTree = m_pTreeGD->GetPTree(); HTREEITEM hItem = pTree->GetSelectedItem(); if (hItem) { CTreeItem* pItem = (CTreeItem*)pTree->GetItemData(hItem); return pItem; } return NULL; }
void CSiteView::OnRemoveSite() { CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndSiteView; HTREEITEM hTreeItem = pWndTree->GetSelectedItem(); SITE_T * site = (SITE_T*)pWndTree->GetItemData(hTreeItem); SiteDAO siteDao; siteDao.DeleteSite(site); FillSiteView(); }
BOOL CdIpmDoc::Initiate(LPCTSTR lpszNode, LPCTSTR lpszServerClass, LPCTSTR lpszUser, LPCTSTR lpszOption) { try { m_connectedInfo.SetNode(lpszNode); if (lpszServerClass) m_connectedInfo.SetServerClass(lpszServerClass); if (lpszUser) m_connectedInfo.SetUser(lpszUser); BOOL bOK = IPM_Initiate(this); if (bOK) { // // LPARAM = 1 (Instruct the view that the function initiate has been invoked) UpdateAllViews(NULL, (LPARAM)1); m_bInitiate = TRUE; // // Create a Thread that periodically scans the DBEvents in order to // update the tree and the right pane: if (!m_pThreadScanDBEvents) { CTreeCtrl* pTree = m_pTreeGD->GetPTree(); ASSERT (pTree); if (pTree) { CfIpmFrame* pIpmFrame = (CfIpmFrame*)pTree->GetParentFrame(); m_ThreadParam.hWndFrame = pIpmFrame? pIpmFrame->m_hWnd: NULL; } m_ThreadParam.hEvent = m_hEventRaisedDBEvents; m_ThreadParam.pIpmDoc = this; m_pThreadScanDBEvents = AfxBeginThread( (AFX_THREADPROC)ThreadControlScanDBEvents, &m_ThreadParam, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED); if (m_pThreadScanDBEvents) ResumeThread(m_pThreadScanDBEvents->m_hThread); } } return bOK; } catch (CeIpmException e) { AfxMessageBox (e.GetReason(), MB_ICONEXCLAMATION|MB_OK); } catch (...) { TRACE0("Exception in: CdIpmDoc::Initiate\n"); } return FALSE; }
void CSiteView::OnRemoveRecorder() { CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndSiteView; HTREEITEM hTreeItem = pWndTree->GetSelectedItem(); RECORDER_T * recorder = (RECORDER_T*)pWndTree->GetItemData(hTreeItem); RecorderDAO recorderDao; recorderDao.DeleteRecorder(recorder->parent, recorder); FillSiteView(); }
HTREEITEM CGrannyListView::InsertModelAOS(CTreeCtrl& tree, HTREEITEM htRoot, Uint32 id, cGrannyModelAOS *model) { const UINT nMask = TVIF_TEXT | TVIF_PARAM; if (!model) return NULL; CString strText; strText.Format("%04d %s", GETID(id), model->desc.c_str()); HTREEITEM htChar = tree.InsertItem(nMask, strText, 0,0,0,0, SETCHAR(id), htRoot, 0); HTREEITEM htPart = tree.InsertItem("part", htChar); //HTREEITEM htAnim = tree.InsertItem("anim", htChar); HTREEITEM htEquip = tree.InsertItem("equip", htChar); std::map <int, cGrannyModelTD *> models = model->models; if (models.empty()) return htEquip; for (std::map<int, cGrannyModelTD*>::iterator i = models.begin(); i != models.end(); i++) { cGrannyModelTD *td = i->second; if (!td) continue; UINT id2 = 0xC000 | id<< 4 | i->first; strText.Format("%2d %s", i->first, cGrannyLoader::GetAosBodyName(i->first).c_str()); HTREEITEM htPart2 = tree.InsertItem(nMask, strText, 0,0,0,0, SETCHAR(id2), htPart, 0); strText.Format("file: %s", td->m_filename.c_str()); tree.InsertItem(strText, htPart2); } if (!model->desc.empty()) { strText.Format("desc: %s", model->desc.c_str()); tree.InsertItem(strText, htChar); } strText.Format("hand: %s", getHandName(model->hand).c_str()); tree.InsertItem(strText, htChar); strText.Format("bone left: %d, right: %d", model->left_hand_bone, model->right_hand_bone); tree.InsertItem(strText, htChar); #if 0 // part animation is same. std::map<int, std::string>& anim_names = models.begin()->second->animation_names; for (std::map<int, std::string>::iterator i = anim_names.begin(); i != anim_names.end(); i++) { strText.Format("%s (%s,%d)", getFileName(i->second).c_str(), AnimTypeData::GetAnimTypeName(i->first).c_str(),i->first); HTREEITEM htItem = tree.InsertItem(nMask, strText, 0,0,0,0, SETANIM(i->first), htAnim,0); strText.Format("file: %s%s", isFileExist(i->second) ? "":"(x) ",i->second.c_str()); tree.InsertItem(strText, htItem); } #endif return htEquip; }
void CdIpmDoc::SearchItem() { CTreeCtrl* pTree = m_pTreeGD->GetPTree(); ASSERT (pTree); if (!pTree) return; CfIpmFrame* pIpmFrame = (CfIpmFrame*)pTree->GetParentFrame(); CvIpmLeft* pView = (CvIpmLeft*)pIpmFrame->GetLeftPane(); if (!pView) return; pView->SearchItem(); }
void CdIpmDoc::ProhibitActionOnTreeCtrl(BOOL bProhibit) { CTreeCtrl* pTree = m_pTreeGD->GetPTree(); ASSERT (pTree); if (!pTree) return; CfIpmFrame* pIpmFrame = (CfIpmFrame*)pTree->GetParentFrame(); CvIpmLeft* pView = (CvIpmLeft*)pIpmFrame->GetLeftPane(); if (!pView) return; pView->ProhibitActionOnTreeCtrl(bProhibit); }
HTREEITEM FindSiblingItem(const CTreeCtrl &rTree, const HTREEITEM hStartingItem, const string &rStr) { HTREEITEM hItem = hStartingItem; while( hItem != NULL ) { if( rTree.GetItemText( hItem ).Compare( rStr.c_str() ) == 0 ) break; else hItem = rTree.GetNextSiblingItem( hItem ); } return hItem; }
// @pymethod object|PyCTreeCtrl|DeleteAllItems|Deletes all items in the control PyObject *PyCTreeCtrl_DeleteAllItems( PyObject *self, PyObject *args ) { if (!PyArg_ParseTuple( args, ":DeleteAllItems")) return NULL; CTreeCtrl *pList = GetTreeCtrl(self); if (!pList) return NULL; GUI_BGN_SAVE; BOOL ok = pList->DeleteAllItems(); GUI_END_SAVE; if (!ok) RETURN_ERR("DeleteAllItems failed"); RETURN_NONE; }
BOOL CDocSelectDlg::OnInitDialog() { CDialog::OnInitDialog(); CTreeCtrl* pTree = (CTreeCtrl*)GetDlgItem(IDC_DOCLIST_TRE); assert(pTree); for (int i = 0; i < m_aDocNames.GetSize(); i++) pTree->InsertItem(m_aDocNames[i]); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
// @pymethod <o PyCEdit>|PyCTreeCtrl|GetEditControl|Retrieves the handle of the edit control used to edit the specified tree view item. PyObject *PyCTreeCtrl_GetEditControl( PyObject *self, PyObject *args ) { CTreeCtrl *pList = GetTreeCtrl(self); if (!pList) return NULL; if (!PyArg_ParseTuple( args, ":GetEditControl")) return NULL; GUI_BGN_SAVE; CEdit *pEdit = pList->GetEditControl(); GUI_END_SAVE; if (pEdit==NULL) RETURN_ERR("GetEditControl failed"); return ui_assoc_object::make(UITypeFromCObject(pEdit), pEdit)->GetGoodRet(); }
void CSiteView::OnPlayRelay() { CFrameWnd * pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd); CHTRecorderManagerView * videoView = (CHTRecorderManagerView*)pFrame->GetActiveView(); if (videoView) { CTreeCtrl* pWndTree = (CTreeCtrl*)&m_wndSiteView; HTREEITEM hTreeItem = pWndTree->GetSelectedItem(); CAMERA_T * camera = (CAMERA_T*)pWndTree->GetItemData(hTreeItem); videoView->StartRelay(camera->parent->uuid, camera->parent->address, camera->parent->username, camera->parent->pwd, camera->uuid, camera->key, 0); } }
void CMainFrame::OnUpdateRegRightDelete(CCmdUI* pCmdUI) { BOOL IsEnable = FALSE; int nItem = -1; CTreeCtrl * pList = &pRegTreeView->GetTreeCtrl(); CListCtrl * pRightList = &pRegListView->GetListCtrl(); HTREEITEM hItem = pList->GetSelectedItem(); nItem = pRightList->GetNextItem(nItem,LVNI_SELECTED); if(hItem != NULL && hItem != pList->GetRootItem() && pRightList->GetSelectedCount() == 1 && pRightList->GetItemText(nItem,0) != "(默认)") IsEnable = TRUE; pCmdUI->Enable(IsEnable); }
//************************************************************************************ void CFavorit::FillTree (CTreeCtrl& wndTree, HTREEITEM htreeItemParent) { for (POSITION pos = m_lstSubItems.GetHeadPosition (); pos != NULL;) { CFavorit* pFavorit = (CFavorit*) m_lstSubItems.GetNext (pos); ASSERT_VALID (pFavorit); HTREEITEM hTreeItem = wndTree.InsertItem (pFavorit->m_strName, pFavorit->m_iIcon, pFavorit->m_iIcon, htreeItemParent); wndTree.SetItemData (hTreeItem, (DWORD_PTR) pFavorit); pFavorit->FillTree (wndTree, hTreeItem); } }
static int CALLBACK DirThenFileAplhaCB(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { int retVal = 0; CTreeCtrl* pTreeCtrl = (CTreeCtrl*)lParamSort; if(pTreeCtrl != NULL) { int img1A, img1B, img2A, img2B; FileTreeItemData* ftidItem1 = (FileTreeItemData*)lParam1; FileTreeItemData* ftidItem2 = (FileTreeItemData*)lParam2; if((ftidItem1 != NULL) && (ftidItem2 != NULL)) { HTREEITEM hItem1 = ftidItem1->hItem; HTREEITEM hItem2 = ftidItem2->hItem; if((hItem1 != NULL) && (hItem2 != NULL)) { pTreeCtrl->GetItemImage(hItem1, img1A, img1B); pTreeCtrl->GetItemImage(hItem2, img2A, img2B); int folderImage = GetSysIlIndex(TEXT("\\")); CString itemStr1 = pTreeCtrl->GetItemText(hItem1); CString itemStr2 = pTreeCtrl->GetItemText(hItem2); if(ftidItem1->isDir && ftidItem2->isDir) { retVal = itemStr1.CompareNoCase(itemStr2); } else if(ftidItem1->isDir) { retVal = -1; } else if(ftidItem2->isDir) { retVal = 1; } else { retVal = itemStr1.CompareNoCase(itemStr2); } } } } return retVal; }
void CIISConfigHelper::RecurseTreeAndSortItems(CTreeCtrl& cTree, HTREEITEM htParent) { if (htParent == NULL) return; cTree.SortChildren(htParent); HTREEITEM htChild = cTree.GetChildItem(htParent); while (htChild != NULL) { RecurseTreeAndSortItems(cTree, htChild); htChild = cTree.GetNextSiblingItem(htChild); } }