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

📄 desdialog.cpp

📁 .net2003下写的多种加密加密算法的演示
💻 CPP
字号:
// DesDialog.cpp : 实现文件
//

#include "stdafx.h"
#include "LmCrypt.h"
#include "DesDialog.h"
#include ".\desdialog.h"


// CDesDialog 对话框

IMPLEMENT_DYNAMIC(CDesDialog, CDialog)
CDesDialog::CDesDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CDesDialog::IDD, pParent)
	, str_input(_T(""))
	, list_sel(0)
	, sel_sel(0)
{
	DocLeft.RemoveAll();
	DocSel.RemoveAll();

}

CDesDialog::~CDesDialog()
{
}

void CDesDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT, str_input);
	DDV_MaxChars(pDX, str_input, 8);
	DDX_Control(pDX, IDC_LIST_DOC, lb_list);
	DDX_Control(pDX, IDC_LIST_SEL, lb_sel);
	DDX_LBIndex(pDX, IDC_LIST_DOC, list_sel);
	DDX_LBIndex(pDX, IDC_LIST_SEL, sel_sel);
}


BEGIN_MESSAGE_MAP(CDesDialog, CDialog)
	ON_BN_CLICKED(IDOK, OnBnClickedOk)
	ON_EN_CHANGE(IDC_EDIT, OnEnChangeEdit)
	ON_BN_CLICKED(IDOK_JIEMI, OnBnClickedJiemi)
	ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
END_MESSAGE_MAP()


// CDesDialog 消息处理程序

BOOL CDesDialog::OnInitDialog()
{
	CDialog::OnInitDialog();

		CDocManager * p_docm=::AfxGetApp()->m_pDocManager;

	   //p_docm->
	   //::AfxGetMainWnd()->get
	
	POSITION pos= ::AfxGetApp()->GetFirstDocTemplatePosition(); 
	 CDocTemplate *pTemplate = ::AfxGetApp()->GetNextDocTemplate(pos);
	 POSITION pos_doc;
     CDocument* m_doc;
	 int i_doccount=p_docm->GetOpenDocumentCount();
	pos_doc=pTemplate->GetFirstDocPosition();
	for(int j=0;j<i_doccount;j++){
	m_doc=pTemplate->GetNextDoc(pos_doc);
	//m_docls[j]=m_doc;
	
	//CListBox * p_listdoc=(CListBox *)GetDlgItem(IDC_LIST_DOC);
	lb_list.AddString(m_doc->GetTitle());
	DocLeft.Add((CObject*)m_doc);
		//s_doc=pTemplate->GetNextDoc();
	}
	CEdit * p_edit=(CEdit *)this->GetDlgItem(IDC_EDIT);
	p_edit->SetWindowText("ustbustb");
	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}

void CDesDialog::OnBnClickedOk()
{

	Encyp();
	OnOK();
}


int CDesDialog::Encyp(void)
{
	//str_input="abcdefgh";
	str_key.MakeLower();
	int i_doccount=DocSel.GetCount();
	for(int i=0;i<i_doccount;i++)
	{
		CDocument* m_subdoc=(CDocument*)DocSel.GetAt(i);
	
	
	CString str_path=m_subdoc->GetPathName();
	CLmDes des;
	des.JiaMi(str_key,str_path);

	}
	return 1;
}


void CDesDialog::OnEnChangeEdit()
{
	// TODO:  如果该控件是 RICHEDIT 控件,则它将不会
	// 发送该通知,除非重写 CDialog::OnInitDialog()
	// 函数并调用 CRichEditCtrl().SetEventMask(),
	// 同时将 ENM_CHANGE 标志“或”运算到掩码中。
	UpdateData();
	str_key=str_input;
	UpdateData();
	// TODO:  在此添加控件通知处理程序代码
}

void CDesDialog::OnBnClickedJiemi()
{
	str_key.MakeLower();
	
	int i_doccount=DocSel.GetCount();
	for(int i=0;i<i_doccount;i++)
	{
		CDocument* m_subdoc=(CDocument*)DocSel.GetAt(i);
	
	CString str_path=m_subdoc->GetPathName();
	CLmDes des;
	des.JieMi(str_key,str_path);

	}
	OnOK();
	
}

void CDesDialog::OnBnClickedButton1()
{
	UpdateData(true);
	//if(lb_list.GetCount()<1||list_sel>=lb_list.GetCount()||list_sel<0)
	if(lb_list.GetCount()<1||list_sel>=lb_list.GetCount()||list_sel<0)
		return;
	
	CString str_title;
	lb_list.GetText(list_sel,str_title);
	lb_sel.AddString(str_title);
	
	DocSel.Add(DocLeft.GetAt(list_sel));
	DocLeft.RemoveAt(list_sel);
    lb_list.DeleteString(list_sel);
	UpdateData(true);
}

void CDesDialog::OnBnClickedButton2()
{
	UpdateData(true);
	//if(lb_sel.GetCount()<1||sel_sel>=lb_list.GetCount()||sel_sel<0)
	if(lb_sel.GetCount()<1||sel_sel>=lb_sel.GetCount()||sel_sel<0)
		return;
	
	CString str_title;
	lb_sel.GetText(sel_sel,str_title);
	lb_list.AddString(str_title);
	
	DocLeft.Add(DocSel.GetAt(sel_sel));
	DocSel.RemoveAt(sel_sel);

	lb_sel.DeleteString(sel_sel);
	UpdateData(true);
}

⌨️ 快捷键说明

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