📄 canceldlg.cpp
字号:
// CancelDlg.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "CancelDlg.h"
#include "CtxMenu.h"
#include "SHUtils.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//regsvr32.exe /s /c $(OUTDIR)\FileCrypt32.dll
/////////////////////////////////////////////////////////////////////////////
// CPPhraseDlg dialog
CPPhraseDlg::CPPhraseDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPPhraseDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPPhraseDlg)
m_csPassPhrase = _T("");
//}}AFX_DATA_INIT
}
void CPPhraseDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPPhraseDlg)
DDX_Control(pDX, EDT_PASSPHRASE, m_EditControl);
DDX_Text(pDX, EDT_PASSPHRASE, m_csPassPhrase);
// DDX_Control(pDX, IDC_HYPERLINK_ME, m_HyperLinkMe);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPPhraseDlg, CDialog)
//{{AFX_MSG_MAP(CPPhraseDlg)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPPhraseDlg message handlers
BOOL CPPhraseDlg::Create(CWnd* pParentWnd)
{
m_parent=pParentWnd;
return CDialog::Create(IDD, pParentWnd);
}
BOOL CPPhraseDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// m_HyperLinkMe.SetURL("mailto:daniel.madden@compaq.com");
CenterWindow();
m_EditControl.SetFocus() ;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPPhraseDlg::OnOK()
{
CFileCrypt32App* pcCryptor = (CFileCrypt32App*) AfxGetApp();
UpdateData();
if (m_csPassPhrase.IsEmpty()) {
int nRet = MessageBox ("Please enter a PassPhrase","Error: PassPhrase",MB_OKCANCEL | MB_ICONEXCLAMATION);
if (nRet == IDOK) {
m_EditControl.SetFocus() ;
GetDlgItem(EDT_PASSPHRASE)->SetWindowText("");
}
else {
pcCryptor->m_csPassPhrase = _T("");
EndDialog (0);
}
}
else {
pcCryptor->m_csPassPhrase = m_csPassPhrase;
EndDialog (1);
}
}
void CPPhraseDlg::OnCancel()
{
CFileCrypt32App* pcCryptor = (CFileCrypt32App*) AfxGetApp();
pcCryptor->m_csPassPhrase = _T("");
EndDialog(0);
}
void CPPhraseDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
m_EditControl.SetFocus() ;
}
void CPPhraseDlg::PostNcDestroy()
{
delete this;
}
/////////////////////////////////////////////////////////////////////////////
// CCancelDlg dialog
CCancelDlg::CCancelDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCancelDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCancelDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_curIcon=0;
}
void CCancelDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCancelDlg)
DDX_Control(pDX, IDCANCEL, m_cancelBtn);
DDX_Control(pDX, IDC_PATH_TEXT, m_pathWnd);
DDX_Control(pDX, IDC_AVI, m_AVI);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCancelDlg, CDialog)
//{{AFX_MSG_MAP(CCancelDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCancelDlg message handlers
BOOL CCancelDlg::Create(CWnd* pParentWnd)
{
m_parent=pParentWnd;
return CDialog::Create(IDD, pParentWnd);
}
void CCancelDlg::PostNcDestroy()
{
// modeless dialogs delete themselves
delete this;
}
void CCancelDlg::ShutDown()
{
DestroyWindow();
}
void CCancelDlg::OnCancel()
{
m_cancelBtn.EnableWindow(FALSE);
SET_SAFE(m_bCancel, TRUE);
}
BOOL CCancelDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CFileCrypt32App* pcCryptor = (CFileCrypt32App*) AfxGetApp();
// Create our passphrase dialog
CPPhraseDlg *dlgPP;
try {
dlgPP = new CPPhraseDlg;
pcCryptor->bDoIt = TRUE;
}
catch (CMemoryException *e) {
e->ReportError();
e->Delete();
dlgPP=NULL;
}
if (pcCryptor->bDoIt) {
//Show passphrase dialog
int result = dlgPP->DoModal ();
if (result != 0) {
SetWindowText(SHELLEXNAME" Is Busy...");
CenterWindow();
SET_SAFE(m_bCancel, FALSE);
}
else {
pcCryptor->bDoIt = FALSE;
}
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCancelDlg::SetPathText(CString csText)
{
m_pathWnd.SetWindowText(csText);
}
void CCancelDlg::StartAVI(void)
{
m_AVI.Open(IDR_AVI); // open the avi resource.
m_AVI.Play((UINT)0, (UINT)-1, (UINT)-1); // play avi resource.
}
void CCancelDlg::StopAVI(void)
{
m_AVI.Stop(); // stop avi resource.
m_AVI.Close(); // close avi resource.
}
BOOL CCancelDlg::IsDirectory(CString csCheck)
{
WIN32_FIND_DATA wfd;
HANDLE hFind;
// Iterate through dirs
hFind = FindFirstFile(csCheck, &wfd);
if (hFind != INVALID_HANDLE_VALUE) {
// Check if "." or "..", if not...
// Check if its a directory.
if ((strcmp(wfd.cFileName,_T("."))) && (strcmp(wfd.cFileName,_T(".."))) &&
(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
// This is a MUST
FindClose(hFind);
return TRUE;
}
// This is a MUST
FindClose(hFind);
}
return FALSE;
}
void CCancelDlg::Split(CString Source, CString Deliminator, CStringArray& AddIt, BOOL bAddEmpty)
{
// initialize the variables
CString newCString = Source;
CString tmpCString = "";
CString AddCString = "";
int pos1 = 0;
int pos = 0;
AddIt.RemoveAll();
if (Deliminator.IsEmpty()) {
// Add default [comma] if empty!
// acknowledgement: Prasad [gprasad@rti.ie]
Deliminator = ",";
}
// do this loop as long as you have a deliminator
do {
// set to zero
pos1 = 0;
// position of deliminator starting at pos1 (0)
pos = newCString.Find(Deliminator, pos1);
// if the deliminator is found...
if ( pos != -1 ) {
// load a new var with the info left
// of the position
CString AddCString = newCString.Left(pos);// - 1);
if (!AddCString.IsEmpty()) {
// if there is a string to add, then
// add it to the Array
AddIt.Add(AddCString);
}
else if (bAddEmpty) {
// if empty strings are ok, then add them
AddIt.Add(AddCString);
}
// make a copy of the of this var. with the info
// right of the deliminator
tmpCString = newCString.Mid(pos + Deliminator.GetLength());
// reset this var with new info
newCString = tmpCString;
}
} while ( pos != -1 );
if (!newCString.IsEmpty()) {
// as long as the variable is not emty, add it
AddIt.Add(newCString);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -