📄 minimaindlg.cpp
字号:
// MiniMainDlg.cpp : implementation file
//
#include "stdafx.h"
#include "minica.h"
#include "MiniMainDlg.h"
#include "SafeDataSetPage.h"
#include ".\Control\aboutctrl\AboutCtrl.h"
#include ".\Control\Splash\SplashWnd.h"
#include ".\GenericClass\Language.h"
#include ".\Control\CreditsCtrl-About\CreditsCtrl.h"
#include "minict.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();
static void TestFunction2(LPCTSTR lpszArg);
static void TestFunction(LPCTSTR lpszArg);
static void DrawCreditsBackground(CDC *pDC, RECT rect, BOOL bAnimate, DWORD lParam);
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
CAboutCtrl m_AboutCtrl;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
CCreditsCtrl m_wndCredits;
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
CString strCredits= "\tMiniCA System V2.0 \n\n"
"\r版本信息:\n"
"MiniCA Bulid 051201\n"
"OPENSSL 0.9.8\n"
"CXPStyleButtonST By Davide Calabro\n"
"CProgressCtrlST By Davide Calabro\n"
"CSuperGridCtrl By Allan Nielsen\n"
"CFileEditCtrl By PJ Arends\n"
"CStaticTreeCtrl By Franc Morales\n"
"CAboutCtrl By Pablo van der Meer\n"
"W3Mfc By PJ Naughter\n"
"ADO classes By Carlos Antollini\n"
"CSplashWnd By Kirk Stowell\n"
"CBitmapSlider By Junho Ryu\n"
"ClassXP 1.2 By Yonsm\n"
"\n\r程序设计:\n"
"hpxs email:hpxs@hotmail.com\n\n"
"\r感谢:\n台中县张凯棠(Commer 卡门)"
"\nemail:commercity@hotmail.com\n"
"协助MiniCA测试\n";
m_AboutCtrl.SetCredits(CMiniCaApp::NormalCode(strCredits), 240, 350, 350);
//滚动文字框的起点位置,宽度,高度
// ____________________
// |
// |
// |
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
DDX_Control(pDX, IDC_ABOUTCTRL, m_AboutCtrl);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
/* srand((unsigned)time(NULL));
// initialize credits control...
// Content
CString s;
s = "<font color='255,255,255' face='arial' size='12' align='center'>";
s += "<font size='28' face='Comic Sans MS' style='ui' color='255,255,255'>Demo Stuff </font><p>";
s += " <font style='bu' align='left'>Color:<br></font><font color='255,0,0'>y</font><font color='220,30,10'>e</font><font color='200,60,30'>e</font><font color='200,100,50'>e</font><font color='180,120,80'>e</font><font color='160,140,100'>e</font><font color='140,160,120'>e</font><font color='120,180,140'>e</font><font color='100,200,160'>e</font><font color='80,180,180'>e</font><font color='60,140,220'>e</font><font color='80,120,250'>h</font><font color='110,100,255'>a</font><font color='130,90,255'>a</font><font color='150,80,255'>a</font><font color='170,70,255'>a</font><font color='180,50,255'>a</font><br>";
s += " <font style='bu' align='left'>Font:<br></font><font color='0,200,100' size='14' face='Comic Sans MS'>Comic Sans MS</font><br><font color='0,200,100' size='14' face='Courier New'>Courier New</font><br><font color='0,200,100' size='14' face='Tahoma'>Tahoma</font><br>";
s += " <font style='bu' align='left'>Size:<br></font><font color='150,100,255'><font size='42'>W</font><font size='36'>H</font><font size='28'>O</font><font size='18'>O</font><font size='14'>O</font><font size='18'>O</font><font size='28'>O</font><font size='36'>O</font><font size='42'>W</font></font><br>";
s += " <font style='bu' align='left'>Styles:<br></font><font color='40,120,240' size='14'><font style='b'>bold</font> <font style='i'>italic</font> <font style='u'>underline</font> <font style='s'>strikeout</font></font><br>";
s += " <font style='bu' align='left'>Background:<br></font><font color='255,255,255' size='14' style='b'><font background='0,0,255'>Blue</font> <font background='255,0,0'>Red</font> <font background='210,150,40'>Brown</font> <font background='0,0,255' color='none'>Ghost Font</font></font><br>";
s += " <font style='bu' align='left'>Alignment:<br></font><font color='255,150,40' size='14' style='b'><font align='right'>right <br></font><font align='center'>center<br></font><font align='left'> left<br></font></font>";
s += " <font style='bu' align='left'>Vertical Alignment:<br></font><font color='0,220,160' size='12' style='b'><font valign='top'>top</font><font valign='middle'>middle</font><font valign='bottom'>bottom</font><font size='48'>BIG</font></font><br>";
s += " <font style='bu' align='left'>Resource Bitmap:<br></font><font color='30,70,255' size='12' style='b'><img src='#%d'><font color='255,0,0'> red </font><font valign='bottom'>bo</font><font valign='middle'>rd</font><font valign='top'>er </font><img src='#%d' border='4' color='255,0,0'></font><br>";
s += " <font style='bu' align='left'>Links:<br></font><font color='100,160,220' size='14' style='b'><a href='#Hello World!#%d' color='100,220,160'>Click Me!</a><br><a href='notepad.exe' color='100,220,160' style='bui'>notepad</a><br><a href='http://www.w3c.org' color='100,220,160' face='Courier New' size='16'>www.w3c.org</a><br><a href='mailto:devix@devix.cjb.net?SUBJECT=Hello World!! ;)' color='100,220,160' face='Comic Sans MS' size='18'>devix@devix.cjb.net</a><br><font size='36' color='255,200,0' style='u'><a href='#\nDo or do not. There is no try.\n\n\t\t-Yoda#%d' color='none' background='255,200,0' style='-uis'>Click Here</a></font><vspace size='4'><font valign='top' size='12' style='-b'>image link: </font><a href='#%d#%d' color='255,200,0'><img src='#%d' border='2' color='none'></a></font><vspace size='80'>";
s += "<font size='28' face='Comic Sans MS' style='ui'>CCreditsCtrl </font><p><font size='18' style='u' color='255,200,0'>About</font><p>Coded in January 2001<br>by <font style='b'>Marc Richarme</font><vspace size='5'><font align='left' size='11'><hspace size='30'><font style='i'>mail: </font><font style='ub'><a href='mailto:devix@devix.cjb.net?SUBJECT=Hello World!' color='255,200,0'>devix@devix.cjb.net</a></font><br><hspace size='30'><font style='i'>web: </font><font style='ub'><a href='http://devix.cjb.net' color='255,200,0'>http://devix.cjb.net</a></font><p></font><font size='18' style='u' color='255,200,0'>Credits</font><p>Thanks to <font style='ub'><a href='http://www.codeproject.com' color='255,200,0'>The Code Project</a></font> for being<br> the coolest VC++/MFC site out there!<br></font><vspace size='80'>";
// Content Data
m_wndCredits.FormatDataString(s,IDB_BACKGROUND,IDB_BACKGROUND,(long)CAboutDlg::TestFunction,
(long)CAboutDlg::TestFunction,(long)this,(long)CAboutDlg::TestFunction2,IDB_BITMAP2);
// use our own function for background drawing
m_wndCredits.m_pBackgroundPaint = CAboutDlg::DrawCreditsBackground;
m_wndCredits.m_dwBackgroundPaintLParam = FALSE;
// as our background is going to be black, use black as default transparent color
m_wndCredits.m_crInternalTransparentColor = RGB(0,0,0);
// now, we're ready to begin... create the window
m_wndCredits.Create(WS_EX_CLIENTEDGE,WS_VISIBLE|WS_CHILD,IDC_ABOUTCTRL,this,0,IDC_SMILEY,0);
*/
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CAboutDlg::DrawCreditsBackground(CDC *pDC, RECT rect, BOOL bAnimate, DWORD lParam)
{
static int on1,on2,oon1,oon2;
pDC->FillSolidRect(&rect,0x00000000);
// uncomment the following lines if you like small green squares :)
// pDC->SetBkColor(0x000000);
// CBrush bgBrush;
// bgBrush.CreateHatchBrush(HS_CROSS,RGB(0,70,30));
// pDC->FillRect(&rect,&bgBrush);
if(bAnimate || (!lParam)) // return now if we are not supposed to do the animation
return;
int n1,n2;
n1 = rand()*200/RAND_MAX-100;
n2 = rand()*200/RAND_MAX-100;
// 2/10 chance of (prehaps) making some wild stuff on one of the curves
if(rand() < RAND_MAX/10)
n1 = rand()*400/RAND_MAX-200;
else if(rand() < RAND_MAX/10)
n2 = rand()*400/RAND_MAX-200;
POINT points1[4] = {
rect.right,0,
(rect.right-rect.left)/2+n1,(rect.bottom-rect.top)/2,
(rect.right-rect.left)/2,(rect.bottom-rect.top)/2-n1,
0,rect.bottom
};
POINT points2[4] = {
0,0,
(rect.right-rect.left)/2-n2,(rect.bottom-rect.top)/2,
(rect.right-rect.left)/2,(rect.bottom-rect.top)/2-n2,
rect.right,rect.bottom
};
POINT opoints1[4] = {
rect.right,0,
(rect.right-rect.left)/2+on1,(rect.bottom-rect.top)/2,
(rect.right-rect.left)/2,(rect.bottom-rect.top)/2-on1,
0,rect.bottom
};
POINT opoints2[4] = {
0,0,
(rect.right-rect.left)/2-on2,(rect.bottom-rect.top)/2,
(rect.right-rect.left)/2,(rect.bottom-rect.top)/2-on2,
rect.right,rect.bottom
};
POINT oopoints1[4] = {
rect.right,0,
(rect.right-rect.left)/2+oon1,(rect.bottom-rect.top)/2,
(rect.right-rect.left)/2,(rect.bottom-rect.top)/2-oon1,
0,rect.bottom
};
POINT oopoints2[4] = {
0,0,
(rect.right-rect.left)/2-oon2,(rect.bottom-rect.top)/2,
(rect.right-rect.left)/2,(rect.bottom-rect.top)/2-oon2,
rect.right,rect.bottom
};
CPen wpen(PS_SOLID,1,RGB(150,220,255));
CPen pen(PS_SOLID,2,RGB(50,100,255));
CPen open(PS_SOLID,1,RGB(50,100,255));
CPen oopen(PS_SOLID,1,RGB(0,30,150));
CPen *pOldPen = pDC->SelectObject(&oopen);
pDC->PolyBezier(oopoints1,4);
pDC->PolyBezier(oopoints2,4);
pDC->SelectObject(&open);
pDC->PolyBezier(opoints1,4);
pDC->PolyBezier(opoints2,4);
pDC->SelectObject(&pen);
pDC->PolyBezier(points1,4);
pDC->PolyBezier(points2,4);
pDC->SelectObject(&wpen);
pDC->PolyBezier(points1,4);
pDC->PolyBezier(points2,4);
pDC->SelectObject(pOldPen);
oon1 = on1;
oon2 = on2;
on1 = n1;
on2 = n2;
}
void CAboutDlg::TestFunction(LPCTSTR lpszArg)
{
if(lpszArg == NULL)
AfxMessageBox("(null)");
else
AfxMessageBox(lpszArg);
}
void CAboutDlg::TestFunction2(LPCTSTR lpszArg)
{
static int cnt = 1;
CAboutDlg *pDlg = (CAboutDlg*)atol(lpszArg);
pDlg->m_wndCredits.m_nTimerSpeed = cnt==0 ? 30 : cnt * 40;
if(++cnt > 3)
cnt = 0;
}
BOOL CAboutDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
// If we get a keyboard or mouse message, hide the splash screen.
if (pMsg->message == WM_KEYDOWN ||
pMsg->message == WM_RBUTTONDOWN ||
pMsg->message == WM_MBUTTONDOWN)
{
OnOK();
}
return CDialog::PreTranslateMessage(pMsg);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CMiniMainDlg dialog
CMiniMainDlg::CMiniMainDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMiniMainDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMiniMainDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_bDlgCreated = false;
m_RegFlag = false;
m_hPageCaItem = NULL;
m_hPageCertWizardSheetItem = NULL;
m_hPageExtItem = NULL;
m_hPageWinEvpSheetItem = NULL;
m_hPageWebSheetItem = NULL;
m_hPageAsn1ParseItem = NULL;
m_hPageCertInfoItem = NULL;
m_hPageRegItem = NULL;
m_hPageCertDbItem = NULL;
m_hPageUpItem = NULL;
m_bHide = FALSE;
m_ImgList.DeleteImageList();
}
void CMiniMainDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMiniMainDlg)
DDX_Control(pDX, IDC_STATIC_LABLE, m_CaptionBarCtrl);
DDX_Control(pDX, IDC_LISTBOX, m_ListBox);
DDX_Control(pDX, IDC_TREE, m_TreeCtrl);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMiniMainDlg, CDialog)
//{{AFX_MSG_MAP(CMiniMainDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_NOTIFY(TVN_SELCHANGING, IDC_TREE, OnSelchangingTree)
ON_NOTIFY(TVN_SELCHANGED, IDC_TREE, OnSelchangedTree)
ON_WM_DESTROY()
ON_WM_CLOSE()
ON_WM_DROPFILES()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMiniMainDlg message handlers
BOOL CMiniMainDlg::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);
// BCMenu * p = BCMenu::UpdateMenu(pSysMenu);
if (pSysMenu != NULL)
{
//删除最大化菜单
pSysMenu->RemoveMenu(SC_ZOOM ,MF_BYCOMMAND);
//删除移动
// pSysMenu->RemoveMenu(SC_MOVE ,MF_BYCOMMAND);
//删除恢复
pSysMenu->RemoveMenu(SC_RESTORE ,MF_BYCOMMAND);
//删除大小
pSysMenu->RemoveMenu(SC_SIZE ,MF_BYCOMMAND);
//修改移动0xF010 - 61456
pSysMenu->ModifyMenu(SC_MOVE , MF_BYCOMMAND, SC_MOVE, "移动(&M)");
//修改最小化 0xF020 - 61472
pSysMenu->ModifyMenu(SC_ICON , MF_BYCOMMAND, SC_ICON, "隐藏(&H)");
//修改关闭0xF060 - 61536
pSysMenu->ModifyMenu(SC_CLOSE , MF_BYCOMMAND, SC_CLOSE, "关闭(&C) Alt + F4");
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_SHOWSPLINT, "观看闪屏(&S) Ctrl+S");
m_LangMenu.LoadMenu(IDR_MENU_LANGUAGE);
// 列出语言
CLanguage::List(m_LangMenu.GetSubMenu(0)->m_hMenu);
pSysMenu->InsertMenu(6, MF_BYPOSITION|MF_POPUP,
(UINT)m_LangMenu.GetSubMenu(0)->m_hMenu, "LangUage"); //语言菜单 ID_MENUSYS_LANGUAGE
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, "关于 MiniCA(&A)..."); //0x0010
// 翻译菜单 bi xu cun zai , fou ze zai fan ti huan jing xiamian bu neng zhengque xianshi fanti zi
CLanguage::TranslateMenu(pSysMenu->m_hMenu, "60000");
}
}
// 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
//XP风格菜单,表现为选中时候图标偏移
BCMenu::SetMenuDrawMode( BCMENU_DRAWMODE_XP );
BCMenu::SetSelectDisableMode(FALSE);
BCMenu::SetXPBitmap3D(TRUE);
// BCMenu::SetIconSize(24,24);
m_ImgList.Create(24,24,TRUE|ILC_COLOR24,20,1);
//24:每个图片的宽度为24
//24:每个图片的高度为24
//TRUE 该图以透明方式显示
//ILC_COLOR24, 颜色数为24位(其他可选常量祥见有关API)
//16: 创建时容量为3个图片
//1: 图片数量超出当前容量时,自动扩容,每次扩容1个图片的容量
HICON hIcon = NULL;
hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ICON_EXTERN), IMAGE_ICON, 24, 24, 0);
m_ImgList.Add(hIcon);//0
DestroyIcon(hIcon);
hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ICON_WIZARD), IMAGE_ICON, 24, 24, 0);
m_ImgList.Add(hIcon);//1 - 数证向导
DestroyIcon(hIcon);
hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ICON_CLIENT), IMAGE_ICON, 24, 24, 0);
m_ImgList.Add(hIcon);//2
DestroyIcon(hIcon);
hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ICON_SERVER), IMAGE_ICON, 24, 24, 0);
m_ImgList.Add(hIcon);//3
DestroyIcon(hIcon);
hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ICON_LOCK), IMAGE_ICON, 24, 24, 0);
m_ImgList.Add(hIcon);//4
DestroyIcon(hIcon);
hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ICON_RA), IMAGE_ICON, 24, 24, 0);
m_ImgList.Add(hIcon);//5
DestroyIcon(hIcon);
hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ICON_ASN1V), IMAGE_ICON, 24, 24, 0);
m_ImgList.Add(hIcon);//6
DestroyIcon(hIcon);
hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ICON_OCSPS), IMAGE_ICON, 24, 24, 0);
m_ImgList.Add(hIcon);//7
DestroyIcon(hIcon);
hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ICON_OCSPC), IMAGE_ICON, 24, 24, 0);
m_ImgList.Add(hIcon);//8
DestroyIcon(hIcon);
hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ICON_VIEWCERT), IMAGE_ICON, 24, 24, 0);
m_ImgList.Add(hIcon);//9
DestroyIcon(hIcon);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -