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

📄 outputbar.cpp

📁 类似vc的集成开发环境
💻 CPP
字号:
// OutputBar.cpp : implementation file
//
/////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "Resource.h"
#include "OutputBar.h"
#include "C02IDE.h"
#include<fstream.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// COutputBar

COutputBar::COutputBar()
{
	NONCLIENTMETRICS ncm;
	memset(&ncm, 0, sizeof(NONCLIENTMETRICS));
	ncm.cbSize = sizeof(NONCLIENTMETRICS);
	VERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
		sizeof(NONCLIENTMETRICS), &ncm, 0));
	_tcscpy( ncm.lfMessageFont.lfFaceName, _T("Courier"));
//	m_Font.CreateFontIndirect(&ncm.lfMessageFont);
	m_Font.CreateFont(13,13,0,0,5,0,0,0, 

    DEFAULT_CHARSET,OUT_DEFAULT_PRECIS, 

       CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH,"宋体"); 

	i_displaycomp=1;
}

COutputBar::~COutputBar()
{
	// TODO: add destruction code here.
}

IMPLEMENT_DYNAMIC(COutputBar, CCJControlBar)

BEGIN_MESSAGE_MAP(COutputBar, CCJControlBar)
	//{{AFX_MSG_MAP(COutputBar)
	ON_WM_CREATE()
	ON_WM_SIZE()
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/*
static CString strBuild[] =
{
	_T("--------------------Configuration: TestApp - Win32 Debug--------------------"),
	_T("Compiling..."),
	_T("TestAppView.cpp"),
	_T("Linking..."),
	_T(""),
	_T("TestApp.exe - 0 error(s), 0 warning(s)"),
};
*/
static CString strBuild="--------------------Configuration: TestApp - Win32 Debug--------------------\nCompiling...\nTestApp.exe - 0 error(s), 0 warning(s)";
static CString strDebug[] =
{
	_T("Loaded 'E:\\WINNT\\System32\\ntdll.dll', no matching symbolic information found."),
	_T("Loaded symbols for 'E:\\WINNT\\system32\\MFC42D.DLL'"),
	_T("Loaded symbols for 'E:\\WINNT\\system32\\MSVCRTD.DLL'"),
	_T("Loaded 'E:\\WINNT\\system32\\KERNEL32.DLL', no matching symbolic information found."),
	_T("Loaded 'E:\\WINNT\\system32\\GDI32.DLL', no matching symbolic information found."),
	_T("Loaded 'E:\\WINNT\\system32\\USER32.DLL', no matching symbolic information found."),
	_T("Loaded 'E:\\WINNT\\system32\\ADVAPI32.DLL', no matching symbolic information found."),
	_T("Loaded 'E:\\WINNT\\system32\\RPCRT4.DLL', no matching symbolic information found."),
	_T("Loaded symbols for 'E:\\WINNT\\system32\\MFCO42D.DLL'")
};

static CString strTabs[] =
{
	"Build",
	"Debug",
	"Find in Files 1",
	"Find in Files 2"
};

/////////////////////////////////////////////////////////////////////////////
// COutputBar message handlers

int COutputBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	//默认控制条的创建
	if (CCJControlBar::OnCreate(lpCreateStruct) == -1)
		return -1;
	//在控制条中添加一个切换控制条
	if (!m_FlatTabCtrl.Create(NULL, "", WS_VISIBLE | WS_CHILD | FTS_HASARROWS | FTS_BOTTOM,
		CRect(10,10,50,25), this, IDC_FLATTAB))
	{
		TRACE0(_T("Unable to create flat tab control bar\n"));
		return -1;
	}
	
	//向控制条中添加按钮及名称字符串
	int nItemCount = sizeof(strTabs)/sizeof(strTabs[0]);
	for( int iItem = 0; iItem < nItemCount; ++iItem)
	{
		m_FlatTabCtrl.InsertItem(iItem, strTabs[iItem]);
	}

//	DWORD dwStyle = WS_CHILD | WS_VISIBLE | LBS_NOINTEGRALHEIGHT | 
//		WS_VSCROLL | WS_TABSTOP| ES_MULTILINE;

	DWORD dwStyle=ES_MULTILINE|WS_VISIBLE|WS_CHILD|WS_VSCROLL|WS_HSCROLL
		| LBS_NOINTEGRALHEIGHT|ES_AUTOHSCROLL|ES_AUTOVSCROLL |ES_READONLY ;
    
	
	//创建各个输出页面
	int nListCount = sizeof(m_OutputList)/sizeof(m_OutputList[0]);
	for( int iList = 0; iList < nListCount; ++iList)
	{

		
		if (!m_OutputList[iList].Create( dwStyle, CRect(0,0,0,0), this,
			IDC_OUTPUT_LIST+iList ))
		{
			TRACE(_T("Failed to create output window.\n"));
			return -1;
		}
		//设置输出页面的字体
		m_OutputList[iList].SetFont( &m_Font );
	}
	
	//向第一个输出页面中添加字符串行
//	int nBuildCount = sizeof(strBuild)/sizeof(strBuild[0]);

//	for( int i = 0; i < nBuildCount; ++i)
	{

//		m_OutputList[0].SetWindowText(strBuild);
//		m_OutputList[0].AddString(strBuild[i]);
	}

	//向第二个输出页面中添加字符串行
//	int nDebugCount = sizeof(strDebug)/sizeof(strDebug[0]);
//	for( i = 0; i < nDebugCount; ++i)
	{
//		m_OutputList[1].AddString(strDebug[i]);
	}

//	m_OutputList[2].AddString(_T("adsfasd"));
	//切换控制条选择第一个
	m_FlatTabCtrl.SetCurSel(0);
	//输出页面选择第一个
	SelectTabView(0);
	return 0;
}

BOOL COutputBar::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) 
{
	if(IDC_FLATTAB == (UINT)wParam)
	{
		NMHDR* pNMHDR = (NMHDR*)lParam;

		switch(pNMHDR->code)
		{
		case TCN_SELCHANGING:
			break;
		case TCN_SELCHANGE:

			SelectTabView(m_FlatTabCtrl.GetCurSel());
			break;
		}
	}
	
	return CCJControlBar::OnNotify(wParam, lParam, pResult);
}

void COutputBar::SelectTabView(int nTab)
{
	int nListCount = sizeof(m_OutputList)/sizeof(m_OutputList[0]);
	for( int iList = 0; iList < nListCount; ++iList) {
		m_OutputList[iList].ShowWindow(SW_HIDE);
	}

	m_OutputList[nTab].ShowWindow(SW_SHOW);
}

void COutputBar::OnSize(UINT nType, int cx, int cy) 
{
	CCJControlBar::OnSize(nType, cx, cy);
	
	if(m_FlatTabCtrl.GetSafeHwnd())
	{
		CRect rc;
		GetChildRect(rc);
		rc.DeflateRect(1,1);

		int nListCount = sizeof(m_OutputList)/sizeof(m_OutputList[0]);
		for( int iList = 0; iList < nListCount; ++iList) {
			m_OutputList[iList].MoveWindow(rc.left, rc.top,
				rc.Width(), rc.bottom-(IsFloating()?18:19));
		}

		m_FlatTabCtrl.MoveWindow(rc.left, rc.bottom-15, rc.Width(), 15);
	}
}

void COutputBar::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	CRect rc;
	m_iAuxImage = (UINT)-1;
	GetClientRect(&rc);
	CRect rect;
	GetChildRect(rect);
	DrawBorders(&dc,rc);
	dc.Draw3dRect(rect, ::GetSysColor(COLOR_3DDKSHADOW),
		::GetSysColor(COLOR_3DDKSHADOW));
}

void COutputBar::UpDateSearch1()
{
	//第三个输出页面内容清空
//	m_OutputList[2].ResetContent();

    //查找信息指针变量
	SearchInf * m_pfinditem;	   
	m_pfinditem =new SearchInf;
			
	//查找结果的条数
	int n_linecount=a_searchinfo.GetSize();
	//添加第一行字符串,
	CString str_addstring=_T("");
	CString str_line;  
	str_addstring=_T("Searching for '")+findstring+_T("'...") ;
//	m_OutputList[2].AddString(str_addstring);
//	m_OutputList[2].SetWindowText(str_addstring);
//    str_addstring=_T("");

    //处理每一个搜索结果
	for( int i = 0; i <n_linecount; i++)
	{
	//获得第i条结果
		m_pfinditem=(SearchInf * )a_searchinfo.GetAt(i);
		//获得结果中的字符串
		str_addstring=str_addstring+"\n"+m_pfinditem->str_linetext;
		//将字符串添加到输出页面中
//		m_OutputList[2].SetWindowText(str_addstring);
//		m_OutputList[2].AddString(str_addstring);
	}
	//将 行数转化为字符串
	str_line.Format("%d",n_linecount);
	//对搜索结果的总结字符串,提示搜索到的总条数
	str_addstring=str_addstring+"\n"+str_line+" occurrence(s) have been found.";
//	m_OutputList[2].AddString(str_addstring);
	m_OutputList[2].SetWindowText(str_addstring);



   //选择切换按钮
	m_FlatTabCtrl.SetCurSel(2);
	//选择输出页面
	SelectTabView(2);
}
/*
void COutputBar::OnLButtonDblClk(UINT nFlags, CPoint point)
{
//	CListCtrl::OnLButtonDblClk(nFlags, point);
	AfxMessageBox("l d ");
	int n_tab=m_FlatTabCtrl.GetCurSel();
	struct SearchInf * inf_search=NULL;
	inf_search=new SearchInf;
	if(n_tab==2)
	{
		int n_selline=0;
		n_selline=	m_OutputList[2].GetCurSel();
		CMDIChildWnd *m_pgotochildf=NULL;
		inf_search=(SearchInf * )a_searchinfo.GetAt(n_selline-1);
		m_pgotochildf=inf_search->m_pchildf;

		CSynEditView *childview = (CSynEditView *)m_pgotochildf->GetActiveView();
   
			CRichEditCtrl& myeditctrl=childview->GetRichEditCtrl();

		if(m_pgotochildf!=NULL)
		{
		m_pgotochildf->MDIActivate(); 
		m_pgotochildf->BringWindowToTop();

	 int nFirst = myeditctrl.GetFirstVisibleLine ();
//	myeditctrl.SetSel(cr);
	 int gotoline=inf_search->n_lineno;
	 int gotorow=inf_search->n_rowno;
    int moveline=gotoline-nFirst;
	myeditctrl.LineScroll(moveline,0);

//	char* linetext=NULL;
	
//	int linesize=myeditctrl.GetLine(gotoline,linetext);
   int linestart=myeditctrl.LineIndex(gotoline);
	CHARRANGE cr;
	cr.cpMin=linestart+gotorow;
	cr.cpMax=linestart+gotorow;
	myeditctrl.SetSel(cr);



		}
	

	}

	

}
*/
int COutputBar::GetSelTab()
{

	return m_FlatTabCtrl.GetCurSel();
}
	
int COutputBar::UpDateComp(CString str_file,CString str_errordir)
{


	if(i_displaycomp==0)
		return 0;

	if(strcmp(str_errordir,"")==0)
	{
		m_OutputList[0].SetWindowText(str_file);
		return 1;
	}
	CString str_addstring=_T("");
	CString str_line=_T("");

	
	CString Str_out=_T("");
	Str_out+="--------------------Copiling project 1--------------------\n";
	Str_out+="Compiling...\n";
	Str_out=Str_out+str_file+"\n";
	str_addstring=Str_out;
	int i_fend=0;
	int i_errnum=0;
//	FILE *pf;
//	if((pf=fopen(str_errordir,"r"))==NULL)
//		return 0;
//	ferr..open(str_errordir,'r');
  
	CFileException fileException;  
	CStdioFile myFile; 
	if(!myFile.Open(str_errordir,CFile::modeRead|CFile::typeText))
		  return 0;
	int i=myFile.GetLength();
	if(myFile.GetLength()!=0)
	do
	{
	i_fend=myFile.ReadString(str_line);
	str_addstring=str_addstring+"\n"+str_line;
	i_errnum++;
	}while (i_fend!=NULL);

	CString str_num=_T("");
	str_num.Format("%d", i_errnum);

	str_addstring=str_addstring+"There are "+str_num+" errors";

	m_OutputList[0].SetWindowText(str_addstring);

	myFile.Close();


	return 1;
}

⌨️ 快捷键说明

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