source: trunk/KeyComboDlg.cpp @ 37

Revision 37, 3.4 KB checked in by lowjoel, 7 years ago (diff)

-As a safety precaution, I've disabled first/last 2k wipes for free space erases.
-Close the registry key when I'm done.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1// KeyComboDlg.cpp
2// $Id$
3//
4// Eraser. Secure data removal. For Windows.
5// Copyright © 1997-2001  Sami Tolvanen (sami@tolvanen.com).
6// Copyright © 2001-2006  Garrett Trant (support@heidi.ie).
7// Copyright © 2007 The Eraser Project
8//
9// This program is free software; you can redistribute it and/or
10// modify it under the terms of the GNU General Public License
11// as published by the Free Software Foundation; either version 2
12// of the License, or (at your option) any later version.
13//
14// This program is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17// GNU General Public License for more details.
18//
19// You should have received a copy of the GNU General Public License
20// along with this program; if not, write to the Free Software
21// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22// 02111-1307, USA.
23
24#include "stdafx.h"
25#include "Eraser.h"
26#include "KeyComboDlg.h"
27#include <shared/key.h>
28#include <commctrl.h>
29
30const LPCTSTR szAccelerKey = "Acceler";
31// CKeyComboDlg dialog
32
33IMPLEMENT_DYNAMIC(CKeyComboDlg, CDialog)
34CKeyComboDlg::CKeyComboDlg(CString wValue /* ="" */, CString strValName /* ="" */, CWnd* pParent /*=NULL*/)
35: CDialog(CKeyComboDlg::IDD, pParent), m_strValue(wValue),m_strRegKey(strValName)
36{
37}
38
39CKeyComboDlg::~CKeyComboDlg()
40{
41}
42
43void CKeyComboDlg::DoDataExchange(CDataExchange* pDX)
44{
45    CDialog::DoDataExchange(pDX);
46    DDX_Control(pDX, IDC_EDITTMP, m_eKey);
47}
48
49
50BEGIN_MESSAGE_MAP(CKeyComboDlg, CDialog)
51    ON_BN_CLICKED(IDOK, OnBnClickedOk)
52    ON_WM_ACTIVATE()
53    ON_EN_CHANGE(IDC_EDITTMP, OnEnChangeEdittmp)
54END_MESSAGE_MAP()
55
56
57// CKeyComboDlg message handlers
58
59BOOL CKeyComboDlg::OnInitDialog()
60{
61    CDialog::OnInitDialog();
62
63    m_eKey.SetLimitText(1);
64    m_eKey.SetWindowText(m_strValue);
65
66    // TODO:  Add extra initialization here
67
68    return TRUE;  // return TRUE unless you set the focus to a control
69    // EXCEPTION: OCX Property Pages should return FALSE
70}
71
72void CKeyComboDlg::OnBnClickedOk()
73{
74    char ch[10];   
75    m_eKey.GetLine(0,ch,1);
76    m_strValue = ch;
77    OnOK();
78}
79
80void CKeyComboDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
81{
82    CDialog::OnActivate(nState, pWndOther, bMinimized);
83    m_eKey.SetFocus();
84    // TODO: Add your message handler code here
85}
86
87
88void CKeyComboDlg::OnEnChangeEdittmp()
89{
90    // TODO:  If this is a RICHEDIT control, the control will not
91    // send this notification unless you override the CDialog::OnInitDialog()
92    // function and call CRichEditCtrl().SetEventMask()
93    // with the ENM_CHANGE flag ORed into the mask.
94    char ch[10];
95    m_eKey.GetLine(0,ch,1);
96    CString strLine(ch);
97    static bool busy = false;
98    if (busy)
99        return;
100    busy = true;
101
102    if (!strLine.Trim().IsEmpty())
103    {
104        CString strTmp(m_strRegKey.MakeUpper());
105        strLine.MakeUpper();
106        if (strTmp.Find(strLine[0]) == -1) {
107            //Invalid selection, clear the entry
108            m_eKey.SetWindowText("m");
109
110            //TODO: This works only with XP/Vista. What about others?
111            EDITBALLOONTIP ebtt;
112            ZeroMemory(&ebtt, sizeof(ebtt));
113            ebtt.cbStruct = sizeof(ebtt);
114            ebtt.pszTitle = L"Invalid shortcut";
115            ebtt.ttiIcon = TTI_ERROR;
116
117            strTmp = "The shortcut value must be one of the characters " + strTmp;
118            ebtt.pszText = new wchar_t[strTmp.GetLength() + 1];
119            mbstowcs((wchar_t*)ebtt.pszText, strTmp.GetBuffer(), strTmp.GetLength() + 1);
120           
121            m_eKey.SendMessage(EM_SHOWBALLOONTIP, 0, (LPARAM)&ebtt);
122            delete[] ebtt.pszText;
123        }
124    }
125    busy = false;
126}
Note: See TracBrowser for help on using the repository browser.