?? sendview.cpp
字號:
// SendView.cpp : implementation of the CSendView class
//
#include "stdafx.h"
#include "ComDbg.h"
#include "ComDbgDoc.h"
#include "SendView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSendView
IMPLEMENT_DYNCREATE(CSendView, CEditView)
BEGIN_MESSAGE_MAP(CSendView, CEditView)
//{{AFX_MSG_MAP(CSendView)
ON_WM_CHAR()
//}}AFX_MSG_MAP
// Standard printing commands
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSendView construction/destruction
CSendView::CSendView()
{
m_pDoc=NULL;
m_pedt=NULL;
LOGFONT lf;
memset(&lf,0,sizeof(lf));
lf.lfCharSet=GB2312_CHARSET;
lf.lfOutPrecision=3;
lf.lfClipPrecision=2;
lf.lfQuality=1;
lf.lfPitchAndFamily=2;
lstrcpy(lf.lfFaceName,_T("宋體"));
lf.lfHeight=-17;
lf.lfWeight=FW_REGULAR;
m_font.CreateFontIndirect(&lf);
}
CSendView::~CSendView()
{
}
BOOL CSendView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CEditView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CSendView drawing
void CSendView::OnDraw(CDC* pDC){}
/////////////////////////////////////////////////////////////////////////////
// CSendView diagnostics
#ifdef _DEBUG
void CSendView::AssertValid() const
{
CEditView::AssertValid();
}
void CSendView::Dump(CDumpContext& dc) const
{
CEditView::Dump(dc);
}
CComDbgDoc* CSendView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CComDbgDoc)));
return (CComDbgDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSendView message handlers
void CSendView::OnInitialUpdate()
{
CEditView::OnInitialUpdate();
m_pDoc=GetDocument();
m_pedt=&GetEditCtrl();
SetFont(&m_font);
}
void CSendView::Clear()
{
m_pedt->SetWindowText(_T(""));
}
void CSendView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// if(!m_pDoc->m_com.IsOpened()) return;
if(nChar == 13) SendCmd();
CEditView::OnChar(nChar,nRepCnt,nFlags);
}
void CSendView::SendCmd()
{
CWaitCursor wait;
union{
WORD w;
struct{
BYTE lb;
BYTE hb;
};
};
CString szTrace=_T("Send: ");
const int bufSize=512;
char szbuf[bufSize]={0};
char sztmp[32]={0};
BYTE bufData[256]={0};
char* p=szbuf;
char* p1=NULL;
CPoint pt=m_pedt->GetCaretPos();
int idx=(m_pedt->CharFromPos(pt)&0xffff0000)>>16;//得到行索引
if(idx<0) return;
int len=m_pedt->GetLine(idx,szbuf,bufSize);
if(len<=0) return;
memset(szbuf+len,0,bufSize-len);
idx=0;
for(;*p!=0;)
{
if((*p>='0' && *p<='9') || (*p>='a' && *p<='f') || (*p>='A' && *p<='f'))
{
sscanf(p,_T("%X"),&w);
bufData[idx]=lb;
idx++;
sprintf(sztmp,"%02X,",(lb&0xff));
szTrace+=sztmp;
while((*p>='0' && *p<='9') || (*p>='a' && *p<='f') || (*p>='A' && *p<='f'))
p++;
}
else p++;
}
Trace(szTrace);
m_pDoc->m_com.Send(bufData,idx);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -