⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tabfileview.cpp

📁 类似vc的集成开发环境
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		CWnd* pWndPopupOwner = this;		
		while (pWndPopupOwner->GetStyle() & WS_CHILD)
	    	pWndPopupOwner = pWndPopupOwner->GetParent();	
		pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, mypoint.x, mypoint.y,
		pWndPopupOwner);

	}

}

void CTabFileView::OnRclick(NMHDR* pNMHDR, LRESULT* pResult) 
{
*pResult = 0;

}

void CTabFileView::OnFuncToshengming() 
{  
	// TODO: Add your command handler code here
	//定义树形项变量
	HTREEITEM hti,hParent,fti,troot;

//	CString fgotofunname,str1,str2;
	//根节点	
	troot=m_pTreeCtrlFile->GetRootItem();
	//根节点的第一个子节点
	fti=m_pTreeCtrlFile->GetChildItem(troot);
    //当前选择节点
	hti=m_pTreeCtrlFile->GetSelectedItem();
	//当前选择节点的父节点
	hParent = m_pTreeCtrlFile->GetParentItem(hti);

	gotofuncname=m_pTreeCtrlFile->GetItemText(hti);
	//当前项目指针
	struct ProjectList * curgotopro=NULL;         
	curgotopro=new ProjectList;
	curgotopro=(ProjectList *)projectinfo.GetAt(0);	
	//项目不存在
	if(curgotopro==NULL||projectinfo.GetSize()==0||curgotopro->proinfstru.GetSize()==0)
		return;
	//函数所在文件的索引
	int n_gotofile=0;
	//项目中的文件数目
	int n_filenum=curgotopro->proinfstru.GetSize();
    //访问每个文件信息
	for(int j=0;j<=n_filenum-1;j++)
	{
		//如果fti是当前选择节点的父节点
		if(hParent==fti)
		{
			//函数所在子窗口指针
			m_pgotochildf=fileitemarray[j].m_pchildf;
		    //所在文件的索引
		    n_gotofile=j;
			break;		  	  
		}
		//取下一个子节点		   
		fti=m_pTreeCtrlFile->GetNextSiblingItem(fti);
	}
	//文件信息结构指针		
	FileList * m_pgotofile=NULL;
	m_pgotofile=new FileList;
    //获得函数所在文件对应的文件信息指针
	m_pgotofile=(FileList * )curgotopro->proinfstru.GetAt(n_gotofile);
	//获得函数所在文件对应的子窗口指针
	m_pgotochildf=fileitemarray[n_gotofile].m_pchildf;
	//断点信息结构的指针变量
	struct FuncStruct * m_ptestfunc;
	m_ptestfunc=new	FuncStruct;
    CString currentname;  
	//断点数目
	int funcsize=m_pgotofile->oa_funcinfstru.GetSize();
	//访问每个函数						
    for(int i=0;i<funcsize;i++)
	{
		//获得第i个断点
		m_ptestfunc=(FuncStruct *)m_pgotofile->oa_funcinfstru.GetAt(i);
 		//断点名称       
		currentname=m_ptestfunc->str_funcname;
         //如果第i个断点是选择的断点 
        if((currentname.Compare(gotofuncname))==0)
		{
			//断点所在行     
		    gotoline=m_ptestfunc->n_shengming; 
		 }
	}
	//子窗口激活
	m_pgotochildf->MDIActivate();
    //子窗口设置为最前
	m_pgotochildf->BringWindowToTop();
    //子窗口设置为焦点
	m_pgotochildf->SetFocus();

//	CCrystalTextView* m_pView=(CCrystalTextView*)m_pgotochildf->GetActiveView();
	CC02IDEView* m_pView=(CC02IDEView*)m_pgotochildf->GetActiveView();

	m_pView->GotoLine(gotoline);
	//向主窗口发送消息,定位到对应的行
//     CWnd* Wnd = AfxGetMainWnd();
//     Wnd->SendMessage(WM_COMMAND, ID_FINDFUNC, 0);	

}


void CTabFileView::OnClick(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	
	*pResult = 0;
}

void CTabFileView::OnLButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	
	CTreeView::OnLButtonUp(nFlags, point);
}

void CTabFileView::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	


	HTREEITEM hti,hParent,fti;
    hParent=m_pTreeCtrlFile->GetRootItem();
	fti=m_pTreeCtrlFile->GetChildItem(hParent);

	hti=m_pTreeCtrlFile->GetSelectedItem();

	struct ProjectList * curtpro=NULL;         
	curtpro=new ProjectList;
	curtpro=(ProjectList *)projectinfo.GetAt(0);
	if(curtpro==NULL||projectinfo.GetSize()==0||curtpro->proinfstru.GetSize()==0)
		return;
	CMDIChildWnd * m_ptestwnd=NULL;
	m_ptestwnd=new CMDIChildWnd ;

	FileList * m_ptfile=NULL;
	m_ptfile=new FileList;

    int n_filenum=curtpro->proinfstru.GetSize();
	if(m_pTreeCtrlFile->GetParentItem(hti)==hParent)
	{
		for(int i=0;i<=n_filenum-1;i++)
		{

	       if(fti==hti)
		   {
			   m_ptestwnd=fileitemarray[i].m_pchildf;
			   break;
		   }
		   fti=m_pTreeCtrlFile->GetNextSiblingItem(fti);
	
	}
	
		
	if(NULL==m_ptestwnd)
		return;
	m_ptestwnd->MDIActivate(); 
	m_ptestwnd->BringWindowToTop();
	}
		else
	{
		if(hti!=hParent)
			OnFuncToshengming();


	}
	CTreeView::OnLButtonDblClk(nFlags, point);
}

void CTabFileView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	
	*pResult = 0;
}

void CTabFileView::NewFile()
{
 /*   
	CMDIFrameWnd *nowframe = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
	
//	CMDIChildWnd *nowchild = nowframe->MDIGetActive();

//	CSynEditView *noweditview = (CSynEditView *)mychild->GetActiveView();
//	CString wndtext;
//    nowchild->GetWindowText(wndtext);

	CWnd* childfrm;
    CString wndtext;
   if(m_pTreeCtrlFile->GetRootItem==NULL)

   {
	   childfrm=nowframe->GetWindow(GW_HWNDNEXT);
	   childfrm->GetWindowText(wndtext);
	   HTREEITEM htiroot = m_pTreeCtrlFile->InsertItem ("project1");
	   HTREEITEM htiParent = m_pTreeCtrlFile->InsertItem (wndtext,1,1,htiroot,TVI_LAST);
   }
   else


   {  
	   AfxMessageBox(IDS_KEY3);
	   BOOL nothave=true;
       HTREEITEM htiparent=m_pTreeCtrlFile->GetRootItem();
	   
       while(!(childfrm=nowframe->GetWindow(GW_HWNDNEXT))==NULL)
	   {  HTREEITEM filechild=m_pTreeCtrlFile->GetChildItem(htiparent);
	      while(!filechild==NULL)
		  {    
		       childfrm->GetWindowText(wndtext);
			  if(m_pTreeCtrlFile->GetItemText(filechild)==wndtext)
				  nothave=false;
			  filechild=m_pTreeCtrlFile->GetChildItem(filechild);
		  }
	   }
	   if(nothave)
	   {
	     HTREEITEM htiparent=m_pTreeCtrlFile->GetChildItem(htiparent);
	     HTREEITEM htichild = m_pTreeCtrlFile->InsertItem (wndtext, 2, 3, htiparent, TVI_LAST);
	   }
   }
   */
}

void CTabFileView::OnFuncToti() 
{
// AfxMessageBox("to functi"); 

	// TODO: Add your command handler code here	
	HTREEITEM hti,hParent,fti,troot;
//	CTreeCtrl &tree = m_tree;
	CString fgotofunname,str1,str2;
	
	troot=m_pTreeCtrlFile->GetRootItem();
	fti=m_pTreeCtrlFile->GetChildItem(troot);

	hti=m_pTreeCtrlFile->GetSelectedItem();
	hParent = m_pTreeCtrlFile->GetParentItem(hti);


	gotofuncname=m_pTreeCtrlFile->GetItemText(hti);

	struct ProjectList * curgotopro=NULL;         
	curgotopro=new ProjectList;
	curgotopro=(ProjectList *)projectinfo.GetAt(0);	
	
	if(curgotopro==NULL||projectinfo.GetSize()==0||curgotopro->proinfstru.GetSize()==0)
		return;
	int n_gotofile=0;
	int n_filenum=curgotopro->proinfstru.GetSize();
//	CMDIChildWnd * m_ptestwnd=NULL;
//	m_ptestwnd=new CMDIChildWnd ;

		for(int j=0;j<=n_filenum-1;j++)
		{



//			m_ptfile=(FileList *)curtpro->proinfstru.GetAt(i);
//		   if(m_ptfile->t_fileitem==hti)
	       if(hParent==fti)
		   {

			   // m_ptestwnd=(CMDIChildWnd *)a_filelist.GetAt(i);

			   m_pgotochildf=fileitemarray[j].m_pchildf;
			   n_gotofile=j;
			   break;			  
		   }
		   fti=m_pTreeCtrlFile->GetNextSiblingItem(fti);


	
		}
	

		

	FileList * m_pgotofile=NULL;
	m_pgotofile=new FileList;

	m_pgotofile=(FileList * )curgotopro->proinfstru.GetAt(n_gotofile);

	m_pgotochildf=fileitemarray[n_gotofile].m_pchildf;

//	 m_pTreeCtrlFile->SetItemState( hti,TVIS_SELECTED ,TVIS_SELECTED); 

//    if(hParent != m_pTreeCtrlFile->GetRootItem())
//    {
     //int linesize=arrayfunc.GetSize();
	 //for (int i=0;i<linesize;i++)
	//	 if(arrayfunc.GetAt(i).Compare(gotofuncname)==0)

	struct FuncStruct * m_ptestfunc;
	m_ptestfunc=new	FuncStruct;
    CString currentname;  	
	int funcsize=m_pgotofile->oa_funcinfstru.GetSize();
					
    for(int i=0;i<funcsize;i++)
	{
		m_ptestfunc=(FuncStruct *)m_pgotofile->oa_funcinfstru.GetAt(i);
        currentname=m_ptestfunc->str_funcname; 
        if((currentname.Compare(gotofuncname))==0)
		{          
		    gotoline=m_ptestfunc->n_dingyi;
		 }
	}

	
	m_pgotochildf->MDIActivate(); 
	m_pgotochildf->BringWindowToTop();
	m_pgotochildf->SetFocus();


  	CC02IDEView* m_pView=(CC02IDEView*)m_pgotochildf->GetActiveView();

	m_pView->GotoLine(gotoline);
    
    

}
/*
void CTabFileView::AddNewFunc()
{


	
	

//		m_pTreeCtrlFile->LockWindowUpdate();

		
	int npro=projectinfo.GetSize();
//		for(int i=0;i<=npro-1;i++)
//		{


		
	struct ProjectList * curpro=NULL;   
	curpro=new ProjectList;           
	curpro=(ProjectList *)projectinfo.GetAt(0);
	CString proname=_T("");
	proname=curpro->str_projectname;

	HTREEITEM hticurpro = m_pTreeCtrlFile->GetRootItem();
	
		
	m_pTreeCtrlFile->Expand (hticurpro , TVE_EXPAND);
			int nfile=curpro->proinfstru.GetSize();

			FileList * m_pcurfile;
         
			m_pcurfile=new FileList;
           
		    CString str_curfilename=_T("");
//			for (int j=0;j<=nfile-1;j++)
//			{		      

//		   ProjectList *m_pcurpro;
//	       m_pcurpro=new ProjectList;
//           curpro=(ProjectList*)(projectinfo.GetAt(0));
	       int n_file=curpro->proinfstru.GetSize();
   

		

				m_pcurfile=(FileList *)curpro->proinfstru.GetAt(0);
				str_curfilename=m_pcurfile->str_filename;
             	HTREEITEM hticurfile; // child item
		
	        	hticurfile= m_pTreeCtrlFile->GetChildItem(hticurpro);

				hticurfile=m_pcurfile->t_fileitem;
		int n_func=m_pcurfile->funcinfstru.GetSize();
				FuncStruct * m_pcurfunc;
				m_pcurfunc=new	FuncStruct;
				
				CString str_curfunc=_T("");
				for(int k=0;k<=n_func-1;k++)
				{

//				if(n_func>=1)
					m_pcurfunc=(FuncStruct *)m_pcurfile->funcinfstru.GetAt(k);
//				else
//					 AfxMessageBox("no this func");

				str_curfunc=m_pcurfunc->str_funcname;

//				AfxMessageBox(str_curfunc);

					HTREEITEM hticurfunc; // child item

	        	    hticurfunc= m_pTreeCtrlFile->InsertItem (str_curfunc, 1, 1, hticurfile, TVI_LAST);
	
					m_pTreeCtrlFile->Expand (hticurfunc , TVE_EXPAND);

	
		
	
				}
//			}

	  
//		}
  

}

void CTabFileView::OnItemexpanding(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
	// TODO: Add your control notification handler code here
	 HTREEITEM hti,hParent;

    hParent=m_pTreeCtrlFile->GetRootItem();
	hti=m_pTreeCtrlFile->GetSelectedItem();

	if(hti==hParent||m_pTreeCtrlFile->GetParentItem(hti)==hParent)

	{
		 CMainFrame* m_Wnd =(CMainFrame*) AfxGetMainWnd();
 //        m_Wnd->ExpandAllFile();
	}

	*pResult = 0;
}
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -