richtestview.cpp

来自「故障诊断工作涉及的领域相当广泛」· C++ 代码 · 共 298 行

CPP
298
字号
// richtestView.cpp : implementation of the CRichtestView class
//

#include "stdafx.h"
#include "richtest.h"
#define RUNMOUDLE 1000001
#include "richtestDoc.h"
#include "CntrItem.h"
#include "richtestView.h"
#include "systeminfo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CRichtestApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CRichtestView
extern CRichtestDoc* thedoc;
IMPLEMENT_DYNCREATE(CRichtestView, CRichEditView)

BEGIN_MESSAGE_MAP(CRichtestView, CRichEditView)
	//{{AFX_MSG_MAP(CRichtestView)
	ON_WM_DESTROY()
	ON_COMMAND(ID_CANCEL_EDIT_SRVR, OnCancelEditSrvr)
	ON_COMMAND(IDD_shuchu, Onshuchu)
	ON_WM_CHAR()
	ON_WM_KEYDOWN()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CRichEditView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CRichEditView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRichEditView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRichtestView construction/destruction

CRichtestView::CRichtestView()
{
	// TODO: add construction code here

}

CRichtestView::~CRichtestView()
{
}

BOOL CRichtestView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CRichEditView::PreCreateWindow(cs);
}

void CRichtestView::OnInitialUpdate()
{
	CRichEditView::OnInitialUpdate();


	// Set the printing margins (720 twips = 1/2 inch).
	SetMargins(CRect(720, 720, 720, 720));
}

/////////////////////////////////////////////////////////////////////////////
// CRichtestView printing

BOOL CRichtestView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}


void CRichtestView::OnDestroy()
{
	// Deactivate the item on destruction; this is important
	// when a splitter view is being used.
   CRichEditView::OnDestroy();
   COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
   if (pActiveItem != NULL && pActiveItem->GetActiveView() == this)
   {
      pActiveItem->Deactivate();
      ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL);
   }
}


/////////////////////////////////////////////////////////////////////////////
// OLE Server support

// The following command handler provides the standard keyboard
//  user interface to cancel an in-place editing session.  Here,
//  the server (not the container) causes the deactivation.
void CRichtestView::OnCancelEditSrvr()
{
	GetDocument()->OnDeactivateUI(FALSE);
}

/////////////////////////////////////////////////////////////////////////////
// CRichtestView diagnostics

#ifdef _DEBUG
void CRichtestView::AssertValid() const
{
	CRichEditView::AssertValid();
}

void CRichtestView::Dump(CDumpContext& dc) const
{
	CRichEditView::Dump(dc);


}

CRichtestDoc* CRichtestView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRichtestDoc)));
	return (CRichtestDoc*)m_pDocument;
}
#endif //_DEBUG
//CFileFind
/////////////////////////////////////////////////////////////////////////////
// CRichtestView message handlers
void CRichtestView::Onshuchu() 
{//char line[200];
	// TODO: Add your command handler code here
	CRichtestDoc* pDoc=GetDocument();
	mydata* pdata=pDoc->sendbag();
	editor2numric one(pdata,this);
	int total_count=one.InputData();
	//pDoc->setcount(total_count);

	
}

void CRichtestView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	
	CRichEditView::OnChar(nChar, nRepCnt, nFlags);
}

void CRichtestView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRichtestDoc)));
	 CRichtestDoc* pdoc=thedoc;
	 //cmdinfo=&(pdoc->cmdinfo);
	BOOL bShift=GetKeyState(VK_SHIFT)&0x80000000;
	CRichEditView::OnKeyDown(nChar, nRepCnt, nFlags);
	 char line[1000];
		GetCaretPos();
		CRichEditCtrl& edit=this->GetRichEditCtrl();
//	BOOL bac=m_bNoAddressChange;
	//	 m_bNoAddressChange=TRUE;
	switch(nChar)
	{	case VK_RETURN+1:
			{int id0=-1,j=0;
			int id=-1;	
				int current_line=edit.GetLineCount();
				for(int i=0;i<current_line;i++)
				{int u;
					int char_count=edit.GetLine(i,line);
					 if(u=search_command(line,char_count)!=-1)
						 id0=u;
					  if(search_command(line,char_count)==RUNMOUDLE)
					 {
						 id=RUNMOUDLE;
						 break;
					 }
				}
				if(id!=RUNMOUDLE)
					id0=id;
				if(id==RUNMOUDLE&&id0!=-1)
				{	int cid[MAX_CONECTOR_COUNT];int cnt;
					getdata_command();
					search_connector(cid,&cnt);
					//check_command(id0);
					run_command(cid,cnt);
				}
				else if(id>-1)
				{
					hint_command(id);
				}
			}

	}

	
	//CRichEditView::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CRichtestView::search_connector(int *pcid,int* pcnt)
{BOOL thehint=TRUE;
	*pcnt=0;
	if(pcmd!=NULL)
	{
		CRichEditCtrl& edit=this->GetRichEditCtrl();
		char* line=new char[1000];
		for(int i=0;i<pcmd->conector_cnt;i++)
		{
			int line_count=edit.GetLineCount();
			for(int j=0;j<line_count;j++)			
			{
				if(searchfor(line,line_count,pcmd->conector[i].function_name,pcmd->conector[i].function_length))
				{thehint=FALSE;
					*(pcid++)=i;
					(*pcnt)++;
					break;
				}
			}	
		}
		delete []line;
		if(thehint)
		{
			*pcid=0;
			*pcnt=1;
		}
	}
	
 	
}

int CRichtestView::search_command(char *line,int char_count)
{char run[5]="运行";
 //CRichtestDoc* pdoc=thedoc;
command* in_pcmd=(command*)theApp.getcmd();////somne wrong ocur
unsigned int cmd_cnt=theApp.getcmd_cnt(-1);
if(cmd_cnt>0)
	{if(searchfor(line,char_count,run,5))
		return RUNMOUDLE;
		for(unsigned int i=0;i<cmd_cnt;i++)
			{	
				if(searchfor(line,char_count,(in_pcmd+i)->cmd_name,(in_pcmd+i)->name_length))
					{pcmd=(command*)in_pcmd+i;
		
					return (in_pcmd+i)->cmd_id;
					}
	
			}
	}	
return -1;
}

void CRichtestView::getdata_command()
{
	CRichtestDoc* pdoc=thedoc;
	CRichtestDoc* pdoc1=this->GetDocument();
	editor2numric item(pdoc1->pdata+pcmd->level*4,this);
	item.InputData();
}

BOOL CRichtestView::check_command(int id)
{
	CRichtestDoc* pdoc=thedoc;
//for(int i=0;i<pdoc->cmd_count;i++)
//{//command* cp=
//	if(i==id)
//	{if(
return TRUE;
}

int CRichtestView::run_command(int* pcid,int cnt)
{
	BOOL thehint=TRUE;
	CRichtestDoc* pdoc=this->GetDocument();
	if(pcmd->go(pdoc->pdata+pcmd->level*4,pcid,cnt)<0)
		return -1;
return 0;
}

void CRichtestView::hint_command(int id)
{


}
BOOL CRichtestView::searchfor(char* pbuffer ,int blth,char* object,int olth)
{int j=0;
	for(int i=0;i<blth-olth;i++)
	{while(*(pbuffer+i+j)==*(object+j))
		j++;
		if(j>=olth-1)
			return TRUE;
	}
	return FALSE;
}



//void CRichtestView::OnSysinfo() 
//{
	// TODO: Add your command handler code here
//	systeminfo item;
	//item.DoModal();
//}

⌨️ 快捷键说明

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