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

📄 encodeview.cpp

📁 用输入的文字进行自动加密处理
💻 CPP
字号:
// EncodeView.cpp : implementation of the CEncodeView class
//

#include "stdafx.h"
#include "Encode.h"

#include "EncodeDoc.h"
#include "EncodeView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CEncodeView

IMPLEMENT_DYNCREATE(CEncodeView, CEditView)

BEGIN_MESSAGE_MAP(CEncodeView, CEditView)
	//{{AFX_MSG_MAP(CEncodeView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CEditView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CEditView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CEditView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEncodeView construction/destruction

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

}

CEncodeView::~CEncodeView()
{
}

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

	BOOL bPreCreated = CEditView::PreCreateWindow(cs);
	cs.style &= ~(ES_AUTOHSCROLL|WS_HSCROLL);	// Enable word-wrapping

	return bPreCreated;
}

/////////////////////////////////////////////////////////////////////////////
// CEncodeView drawing

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

/////////////////////////////////////////////////////////////////////////////
// CEncodeView printing

BOOL CEncodeView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default CEditView preparation
	return CEditView::OnPreparePrinting(pInfo);
}

void CEncodeView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
	// Default CEditView begin printing.
	CEditView::OnBeginPrinting(pDC, pInfo);
}

void CEncodeView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
{
	// Default CEditView end printing
	CEditView::OnEndPrinting(pDC, pInfo);
}

/////////////////////////////////////////////////////////////////////////////
// CEncodeView diagnostics

#ifdef _DEBUG
void CEncodeView::AssertValid() const
{
	CEditView::AssertValid();
}

void CEncodeView::Dump(CDumpContext& dc) const
{
	CEditView::Dump(dc);
}

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

/////////////////////////////////////////////////////////////////////////////
// CEncodeView message handlers

void CEncodeView::SerializeRaw(CArchive &ar)
{
CEdit& theEdit = GetEditCtrl(); //取得编辑控件 
CString tempStr;    
 LPTSTR  p; 
 if(ar.IsStoring ()) 
 {   
	 int length=theEdit.GetWindowTextLength ();   //得到编辑控件中文本长度  
	 p=tempStr.GetBuffer(length);  
	 theEdit.GetWindowText (p,length+1);   //得到编辑控件中文本  
	 int i=0;   
	 while(p[i])     //用0x80作为密匙加密  
	 {     
		 p[i]^=0x80;    
		 i++;   
	 }   
	 tempStr.ReleaseBuffer ();   
	 ar<<tempStr;    //写文件 
 } 
	 else
	 { 
		 ar>>tempStr;    //读文件 
	 p=tempStr.GetBuffer(tempStr.GetLength()); 
	 int i=0; 
	 while(p[i])     //用0x80作为密匙解密 
	 {
		 p[i]^=0x80; 
	 i++; 
	 } 
	 tempStr.ReleaseBuffer (); 
	 theEdit.SetWindowText (tempStr);
	 }
}

⌨️ 快捷键说明

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