📄 1478dlg.cpp
字号:
// 1478Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "1478.h"
#include "1478Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMy1478Dlg dialog
CMy1478Dlg::CMy1478Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CMy1478Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMy1478Dlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMy1478Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMy1478Dlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMy1478Dlg, CDialog)
//{{AFX_MSG_MAP(CMy1478Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMy1478Dlg message handlers
BOOL CMy1478Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CMy1478Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMy1478Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
//AfxMessageBox("asdf");
char shou_1[]=" 在本程序加密的过程中,只加密小写字母,其余的符号,在加密的过程中被忽略!\0";
char shou_2[]=" 在本程序解密的过程中,只要遇见不能够解密的密文就马上退出解密过程!\0";
this->SetDlgItemText(IDC_EDIT_Text,shou_1);
this->SetDlgItemText(IDC_EDIT_Text_code,shou_2);
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMy1478Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMy1478Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
CString a,b;
char table[6][6]={
{' ','a','b','c','d','e'},
{'h','a','c','d','j','k'},
{'i','b','e','i','l','s'},
{'j','f','h','m','r','t'},
{'k','g','n','q','u','x'},
{'l','o','p','v','w','y'},
};
char text[500],temp,temp_i=0;
this->GetDlgItemText(IDC_EDIT_Text,a);
int len=a.GetLength(),i=0;
for(i=0;i<500;i++)text[i]='\0';
//if(len==0)AfxMessageBox("ase",1,4);
//if(len<=5)AfxMessageBox("len<=5",1,4);
for(i=1;i<=len;i++)
{
int j,k;
int mark=0;
temp=a.GetAt(i-1);
for(j=1;j<=5;j++)
{
for(k=1;k<=5;k++)
{
if(table[j][k]==temp)
{
text[temp_i++]=table[0][k];
text[temp_i++]=table[j][0];
mark=1;
break;
}
}
}
if(mark==0)
{
if(temp=='z')
{
//AfxMessageBox("mark==0",1);
text[temp_i++]=text[temp_i++]=temp;
}
else
{
}
}
//AfxMessageBox("mark==2",1);
}
//text[2*(i-1)]='\0';
AfxMessageBox("加密过程完毕!");
this->SetDlgItemText(IDC_EDIT_Text_code,text);
//AfxMessageBox(ase,1,4);
}
void CMy1478Dlg::OnButton2()
{
// TODO: Add your control notification handler code here
char table[6][6]={
{' ','a','b','c','d','e'},
{'h','a','c','d','j','k'},
{'i','b','e','i','l','s'},
{'j','f','h','m','r','t'},
{'k','g','n','q','u','x'},
{'l','o','p','v','w','y'},
};
CString a;
this->GetDlgItemText(IDC_EDIT_Text_code,a);
int len=a.GetLength();
int i=0;
char text[500];
int text_i=0,text_mark=0;
for(i=0;i<500;i++)text[i]='\0';
i=0;
while(1)
{
char temp1,temp2;
int mark=0,mark_text=0;
if(i<len){temp1=a.GetAt(i++);mark++;}
if(i<len){temp2=a.GetAt(i++); mark++; }
if(mark==2)
{
int j;
for(j=1;j<6;j++)
{
if(table[0][j]==temp1)
{
int k;
for(k=1;k<6;k++)
{
if(table[k][0]==temp2)
{
text[text_i++]=table[k][j];
//text[text_i++]=temp2;
mark_text=1;
break;
}
}
break;
}
}
if(mark_text==0)
{
AfxMessageBox("密文错误,解密过程终止!");
break;
}
}
else
{
if(mark==0)AfxMessageBox("密文解密过程完毕!");
else AfxMessageBox("密文错误,解密过程终止!");
break;
}
}
this->SetDlgItemText(IDC_EDIT_Text,text);
}
void CMy1478Dlg::OnButton3()
{
// TODO: Add your control notification handler code here
this->SetDlgItemText(IDC_EDIT_Text,"");
}
void CMy1478Dlg::OnButton4()
{
// TODO: Add your control notification handler code here
this->SetDlgItemText(IDC_EDIT_Text_code,"");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -