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

📄 passwddialog.cpp

📁 AES, 即Advanced Encryption Standard高级加密标准模块, 它是目前国际上最先进的加密技术, 是基于DES之后的最新发布的高段加密标准. 该标准由美国NIST(Nation
💻 CPP
字号:
/*
 *  PasswdDialog.cpp
 *
 *  Copyright (C) 2006
 *  Paul E. Jones <paulej@arid.us>
 *  All Rights Reserved.
 *
 ******************************************************************************
 *  $Id: PasswdDialog.cpp,v 1.3 2008/05/26 01:07:25 paulej Exp $
 ******************************************************************************
 *
 *  This module implements a simple dialog box for prompting the user for
 *  a password.
 *
 */


#include "stdafx.h"
#include "PasswdDialog.h"

/*
 *  PasswdDialog Constructor
 */
PasswdDialog::PasswdDialog()
{
}

/*
 *  PasswdDialog Destructor
 */
PasswdDialog::~PasswdDialog()
{
}

/*
 *  OnInitDialog
 */
LRESULT PasswdDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    HWND window_handle;
    HICON hicon;

    CAxDialogImpl<PasswdDialog>::OnInitDialog(uMsg, wParam, lParam, bHandled);
    bHandled = TRUE;

    hicon = (HICON) ::LoadImage(_AtlBaseModule.GetResourceInstance(),
                                MAKEINTRESOURCE(IDI_AESCRYPT),
                                IMAGE_ICON,
                                LR_DEFAULTSIZE,
                                LR_DEFAULTSIZE,
                                LR_SHARED);
        
    SetIcon(hicon);
                    
    CenterWindow(GetForegroundWindow());

    // Limit the length of text in the password boxes to
    // MAX_PASSWD_LEN characters
    SendDlgItemMessage( IDC_PASSWD,
                        EM_SETLIMITTEXT,
                        MAX_PASSWD_LEN,
                        0);
    if (lParam)
    {
        encrypting = true;

        SendDlgItemMessage( IDC_PASSWDCONFIRM,
                            EM_SETLIMITTEXT,
                            MAX_PASSWD_LEN,
                            0);
    }
    else
    {
        encrypting = false;

        // Hide the password confirmation controls
        window_handle = GetDlgItem(IDC_PASSWDCONFIRM);
        ::ShowWindow(window_handle, SW_HIDE);
        window_handle = GetDlgItem(IDC_ENTERPASSWDCONFIRM);
        ::ShowWindow(window_handle, SW_HIDE);
    }
    
    return 1;  // Let the system set the focus
}

/*
 *  OnClickedOK
 */
LRESULT PasswdDialog::OnClickedOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
    TCHAR passwdconfirm[MAX_PASSWD_LEN+2];

    GetDlgItemText( IDC_PASSWD,
                    passwd,
                    MAX_PASSWD_LEN);
    
    // If we are encrypting files, check to make sure that the
    // password entered into the conformation field matches.
    // If decrypting, the confirmation is not necessary.
    if (encrypting)
    {
        GetDlgItemText( IDC_PASSWDCONFIRM,
                        passwdconfirm,
                        MAX_PASSWD_LEN);

        if (_tcscmp(passwd,passwdconfirm))
        {
            MessageBox( _T("Password confirmation check failed.\nVerify that the passwords match."),
                        _T("AES Crypt"),
                        MB_OK);
        }
        else if (_tcsnlen(passwd, MAX_PASSWD_LEN) == 0)
        {
            MessageBox( _T("You failed to enter a password."),
                        _T("AES Crypt"),
                        MB_OK);
        }
        else
        {
                    EndDialog(wID);
        }
    }
    else
    {
        if (_tcsnlen(passwd, MAX_PASSWD_LEN) == 0)
        {
            MessageBox( _T("You failed to enter a password."),
                        _T("AES Crypt"),
                        MB_OK);
        }
        else
        {
            EndDialog(wID);
        }
    }

    return 0;
}

/*
 *  OnClickedCancel
 */
LRESULT PasswdDialog::OnClickedCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
    EndDialog(wID);
    return 0;
}

⌨️ 快捷键说明

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