📄 pkidlg.cpp
字号:
// PKIDlg.cpp : implementation file
//
#include "stdafx.h"
#include "PKI.h"
#include "PKIDlg.h"
#include "SignDlg.h"
#include "VeriDlg.h"
//#include "Main1Dlg.h"
#include "DES1Dlg.h"
#include "AES1Dlg.h"
#include "SetDlg.h"
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <wincrypt.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()
/////////////////////////////////////////////////////////////////////////////
// CPKIDlg dialog
CPKIDlg::CPKIDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPKIDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPKIDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON1);
}
void CPKIDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPKIDlg)
DDX_Control(pDX, IDC_STATICLOADPICTURE, mPicture);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPKIDlg, CDialog)
//{{AFX_MSG_MAP(CPKIDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_COMMAND(IDC_ABOUT_MENU, OnAboutMenu)
ON_BN_CLICKED(IDC_BUTTONDES, OnButtondes)
ON_BN_CLICKED(IDC_BUTTONAES, OnButtonaes)
ON_BN_CLICKED(IDC_BUTTONSIGN, OnButtonsign)
ON_BN_CLICKED(IDC_BUTTONARCSIGN, OnButtonarcsign)
ON_BN_CLICKED(IDC_BUTTON1, OnButtonLoadPicture)
ON_BN_CLICKED(IDC_BUTTON2, OnButtonInsertMessage)
ON_BN_CLICKED(IDC_BUTTON3, OnPick)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPKIDlg message handlers
BOOL CPKIDlg::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 CPKIDlg::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 CPKIDlg::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();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CPKIDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CPKIDlg::OnAboutMenu()
{
// TODO: Add your command handler code here
CAboutDlg dlg;
dlg.DoModal();
}
void CPKIDlg::OnButtondes() //DES加密算法
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
CDES1Dlg dlg;
dlg.DoModal();
}
void CPKIDlg::OnButtonaes() //AES加密算法
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
CAES1Dlg dlg;
dlg.DoModal();
}
void CPKIDlg::OnButtonsign() //数字签名
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
CSignDlg dlg;
dlg.DoModal();
}
void CPKIDlg::OnButtonarcsign() //数字签名认证
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
CVeriDlg dlg;
dlg.DoModal();
}
void CPKIDlg::OnButtonLoadPicture()
{
// TODO: Add your control notification handler code here
static char szFilter[]="BMP Files(*.BMP)|*.BMP||";
CFileDialog FileDlg(TRUE, NULL, NULL,
OFN_HIDEREADONLY, szFilter);
if(FileDlg.DoModal() ==IDOK &&
m_Dib.Load(FileDlg.GetPathName())){
//InvalidateRect(NULL,TRUE);
HBITMAP hbmp = (HBITMAP)::LoadImage(NULL,
FileDlg.GetPathName(),IMAGE_BITMAP,0,0,
LR_CREATEDIBSECTION|LR_LOADFROMFILE);
mPicture.SetBitmap(hbmp);
UpdateWindow();
have_open_a_file=true;
if (m_Dib.tag == 0)//该图无隐藏信息
{
//embed = true;
//pick = false; //菜单亮暗控制
GetDlgItem(IDC_BUTTON3)->EnableWindow(false);
GetDlgItem(IDC_BUTTON2)->EnableWindow(true);
}//
else
{
//embed = false;
//pick = true; //菜单亮暗控制
AfxMessageBox("该文件已嵌入水印信息,请提取!!");
GetDlgItem(IDC_BUTTON2)->EnableWindow(false);
GetDlgItem(IDC_BUTTON3)->EnableWindow(true);
}//
}
}
void CPKIDlg::OnButtonInsertMessage()
{
// TODO: Add your control notification handler code here
static char szFilter[] = "All Files(*.*)|*.*||";
//aGetDlgItem(IDC_BUTTON2)->EnableWindow(false);
CFileDialog FileDlg( TRUE, NULL, NULL,
OFN_HIDEREADONLY, szFilter );
if( FileDlg.DoModal() == IDOK &&
m_Dib.LoadEmbFile( FileDlg.GetPathName() ) )
{
if (m_Dib.bitmap_size / m_Dib.embfile_size < 8)
{
AfxMessageBox("文件太大,无法嵌入!");
}
else
{
show_contrast = true;
m_Dib.BackUpDib(); //图片原始数据备份供对比显示
m_Dib.Embed(); //嵌入
Invalidate(true);//刷屏,显示加入隐藏信息后的图像
static char szFilter[] = "BMP Files(*.BMP)|*.BMP||";
CFileDialog FileDlg( FALSE, "bmp", NULL, //保存
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter );
if( FileDlg.DoModal() == IDOK )
{
m_Dib.Save( FileDlg.GetPathName() );
}
HBITMAP hbmp = (HBITMAP)::LoadImage(NULL, FileDlg.GetPathName(),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE);
//mSpic.SetBitmap(hbmp);
//embed = false;
}
}
}
void CPKIDlg::OnPick()
{
// TODO: Add your control notification handler code here
//提取完毕,弹出保存对话框,用户进行保存
static char szFilter[] = "All Files(*.*)|*.*||";
CFileDialog FileDlg( FALSE, "", NULL, //保存
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter );
if (FileDlg.DoModal() == IDOK)
{
m_Dib.Pick();
m_Dib.SavePicked(FileDlg.GetPathName());
pick = false;
}
}
void CPKIDlg::OnButton4()
{
// TODO: Add your control notification handler code here
CAboutDlg dlg;
dlg.DoModal();
}
void CPKIDlg::OnButton5()
{
// TODO: Add your control notification handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -