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

📄 userextinfodlg.cpp

📁 可以实现一个简单的CA发放证书更新证书等等功能。
💻 CPP
字号:
// UserExtInfoDlg.cpp : implementation file
//

#include "stdafx.h"
#include "CisoCA.h"
#include "UserExtInfoDlg.h"
#include "UserMakeCertSheet.h"

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

/////////////////////////////////////////////////////////////////////////////
// CUserExtInfoDlg dialog
IMPLEMENT_DYNCREATE(CUserExtInfoDlg, CPropertyPage)

CUserExtInfoDlg::CUserExtInfoDlg(CWnd* pParent /*=NULL*/)
	: CPropertyPage(CUserExtInfoDlg::IDD)
{
	//{{AFX_DATA_INIT(CUserBaseInfoDlg)
		// NOTE: the ClassWizard will add member initialization here
	m_len=_T("");
	m_pwd=_T("");
	m_pverify=_T("");
	//}}AFX_DATA_INIT
	pSheet = (CPropertySheet*)pParent;
	certFormat = 0; // p12
}


void CUserExtInfoDlg::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CUserExtInfoDlg)
	DDX_Control(pDX, IDC_RADIO_PEM, m_pem);
	DDX_Control(pDX, IDC_RADIO_P12, m_p12);
	DDX_Control(pDX, IDC_USER_KEYLEN, m_klen);
	DDX_Text(pDX, IDC_USER_PWD, m_pwd);
	DDX_Text(pDX, IDC_USER_PWD_VERIFY, m_pverify);
	DDX_Text(pDX, IDC_USER_VALID, m_valid);
	DDX_Text(pDX, IDC_USER_FRIEND, m_friendName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CUserExtInfoDlg, CPropertyPage)
	//{{AFX_MSG_MAP(CUserExtInfoDlg)
	ON_CBN_EDITCHANGE(IDC_USER_KEYLEN, OnEditchangeUserKeylen)
	ON_CBN_SELCHANGE(IDC_USER_KEYLEN, OnSelchangeUserKeylen)
	ON_BN_CLICKED(IDC_RADIO_P12, OnRadioP12)
	ON_BN_CLICKED(IDC_RADIO_PEM, OnRadioPem)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUserExtInfoDlg message handlers

BOOL CUserExtInfoDlg::OnSetActive() 
{
	// TODO: Add your specialized code here and/or call the base class
	((CUserMakeCertSheet*)pSheet)->SetWizardButtons(PSWIZB_BACK|PSWIZB_NEXT);	
	return CPropertyPage::OnSetActive();
}

BOOL CUserExtInfoDlg::OnWizardFinish() 
{
	// TODO: Add your specialized code here and/or call the base class

	return TRUE;
}

BOOL CUserExtInfoDlg::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here
	((CEdit*)GetDlgItem(IDC_USER_VALID))->SetWindowText("365");
	m_klen.AddString("512");
	m_klen.AddString("768");
	m_klen.AddString("1024");
	m_klen.AddString("2048");
	m_klen.SetCurSel(2);
	//组合框的第一个子窗口就是编辑控件
	CEdit* pe=(CEdit*)(GetDlgItem(IDC_USER_KEYLEN)->GetWindow(GW_CHILD));
	pe->EnableWindow(TRUE);   
	//使编辑窗口生效,并且设置为只读
	pe->SetReadOnly();
	m_p12.SetCheck(1);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CUserExtInfoDlg::OnEditchangeUserKeylen() 
{
	// TODO: Add your control notification handler code here
	m_klen.Clear();
	m_klen.AddString("512");
	m_klen.AddString("768");
	m_klen.AddString("1024");
	m_klen.AddString("2048");
	m_klen.SetCurSel(2);	
}

void CUserExtInfoDlg::OnSelchangeUserKeylen() 
{
	// TODO: Add your control notification handler code here
	
}

void CUserExtInfoDlg::OnRadioP12() 
{
	// TODO: Add your control notification handler code here
	certFormat  =  0;
	m_p12.SetCheck(1);
	m_pem.SetCheck(0);
	((CEdit*)GetDlgItem(IDC_USER_FRIEND))->EnableWindow(TRUE);
}

void CUserExtInfoDlg::OnRadioPem() 
{
	// TODO: Add your control notification handler code here
	certFormat  =  1;
	m_p12.SetCheck(0);
	m_pem.SetCheck(1);
	((CEdit*)GetDlgItem(IDC_USER_FRIEND))->EnableWindow(FALSE);
}

LRESULT CUserExtInfoDlg::OnWizardNext() 
{
	// TODO: Add your specialized code here and/or call the base class
	(GetDlgItem(IDC_USER_PWD))->GetWindowText(m_pwd);
	(GetDlgItem(IDC_USER_PWD_VERIFY))->GetWindowText(m_pverify);
	(GetDlgItem(IDC_USER_VALID))->GetWindowText(m_valid);
	if(m_valid.IsEmpty())
	{
		AfxMessageBox("有效期不能为空!\n\n有效期以天为单位!");
		return -1L;
	}
	if( m_pwd.Compare(m_pverify) != 0 )
	{
		
		::MessageBox(NULL,"密码不匹配,请重新输入!","系统提示",
			MB_OK|MB_ICONEXCLAMATION);
		(GetDlgItem(IDC_USER_PWD))->SetWindowText(_T(""));
		(GetDlgItem(IDC_USER_PWD_VERIFY))->SetWindowText(_T(""));
//		((CUserMakeCertSheet*)pSheet)->SetActivePage(this);
		return -1L;
	}
	int idx = m_klen.GetCurSel();
	m_klen.GetLBText(idx,m_len);
	return 0L;
	return CPropertyPage::OnWizardNext();
}

⌨️ 快捷键说明

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