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

📄 comdebugview.cpp

📁 用多线程技术编写串行通信协议
💻 CPP
字号:
// comdebugView.cpp : implementation of the CComdebugView class
//

#include "stdafx.h"
#include "comdebug.h"
#include "comdebugDoc.h"
#include "comdebugView.h"
#include "mainfrm.h"

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

/////////////////////////////////////////////////////////////////////////////
// CComdebugView

IMPLEMENT_DYNCREATE(CComdebugView, CScrollView)

BEGIN_MESSAGE_MAP(CComdebugView, CScrollView)
	//{{AFX_MSG_MAP(CComdebugView)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CComdebugView construction/destruction

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

}

CComdebugView::~CComdebugView()
{
}

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

	return CScrollView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CComdebugView drawing

void CComdebugView::OnDraw(CDC* pDC)
{
	CComdebugDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

void CComdebugView::OnInitialUpdate()
{
	CScrollView::OnInitialUpdate();

	CSize sizeTotal;
	// TODO: calculate the total size of this view
	sizeTotal.cx = sizeTotal.cy = 100;
	SetScrollSizes(MM_TEXT, sizeTotal);
}


/////////////////////////////////////////////////////////////////////////////
// CComdebugView diagnostics

#ifdef _DEBUG
void CComdebugView::AssertValid() const
{
	CScrollView::AssertValid();
}

void CComdebugView::Dump(CDumpContext& dc) const
{
	CScrollView::Dump(dc);
}

CComdebugDoc* CComdebugView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CComdebugDoc)));
	return (CComdebugDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CComdebugView message handlers

void CComdebugView::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	dc.SetBkMode(TRANSPARENT);
	CMainFrame *mainframe=(CMainFrame *)GetParentFrame();
	CComdebugDoc* pDoc = GetDocument();
	switch(mainframe->paintcase)
	{
	case PAINT_COMMUICAT:					
			{	
				
				CString displaystr,disponerow ;
				instrsize.cx=0;
				instrsize.cy=0;

				if(pDoc->inputdata.IsEmpty())
				return;

				CSize size;
				size=dc.GetTextExtent(pDoc->inputdata,1);
				sizeTotal.cy=pDoc->linenum*size.cy; 
				CSize scrollsize(10000,0);
				scrollsize.cy=sizeTotal.cy;
				scrollsize.cy+=3*size.cy;
				CRect winrect;
				GetWindowRect(&winrect);
				SetScrollSizes(MM_TEXT, scrollsize);

				if((pDoc->linenum>pervlinenum)&&((winrect.bottom-winrect.top)<scrollsize.cy))
				{
					SetScrollPos( SB_VERT,scrollsize.cy,TRUE );
				}

	
				displaystr=pDoc->inputdata;
				displaystr.TrimRight();	
				int strleng=displaystr.GetLength();
				int y=0;
				OnPrepareDC(&dc);
				while(TRUE)
				{
					strleng=displaystr.GetLength();
					int a=displaystr.Find("\r\n");	
					if(a>0)
					{
						disponerow=displaystr.Left(a);
						displaystr=displaystr.Right(strleng-a);
					}
					if(a==0)
					{
						displaystr=displaystr.Right(strleng-2);
						instrsize.cy+=size.cy;
						continue;
					}
					if(a==-1)
					{
						disponerow=displaystr;
						if(disponerow.Find("*")>=0)
						instrsize.cx=0;
						else
						{
							disponerow.TrimLeft();
							instrsize.cx=size.cx*10;
						}
						dc.TextOut(instrsize.cx,instrsize.cy,disponerow);
						break;
					}

					if(disponerow.Find("*")>=0)
						instrsize.cx=0;
					else
					{
						disponerow.TrimLeft();
						instrsize.cx=size.cx*10;
					}
					dc.TextOut(instrsize.cx,instrsize.cy,disponerow);
				}


				if(pDoc->linenum==pervlinenum)
					return;	
	
				int addsize=(pDoc->linenum-pervlinenum)*size.cy;
				CPoint totalsize=GetTotalSize();
				totalsize.y+=addsize;

				if((pDoc->linenum>pervlinenum)&&((winrect.bottom-winrect.top)<scrollsize.cy))
					SetScrollPos( SB_VERT,totalsize.y,TRUE );

				pervlinenum=pDoc->linenum;
			
				break;
			}		
		default:break;
		}		// Do not call CScrollView::OnPaint() for painting messages
}

⌨️ 快捷键说明

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