// EditKey.cpp : implementation file // #include "stdafx.h" #include "dclient.h" #include "EditKey.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CEditKey dialog CEditKey::CEditKey(CString csText, CWnd* pParent /*=NULL*/) : CDialog(CEditKey::IDD, pParent) { //{{AFX_DATA_INIT(CEditKey) m_csKey = csText; //}}AFX_DATA_INIT } void CEditKey::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CEditKey) DDX_Text(pDX, IDC_EDIT_KEY, m_csKey); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CEditKey, CDialog) //{{AFX_MSG_MAP(CEditKey) ON_EN_CHANGE(IDC_EDIT_KEY, OnChangeEditKey) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CEditKey message handlers void CEditKey::OnChangeEditKey() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function to send the EM_SETEVENTMASK message to the control // with the ENM_CHANGE flag ORed into the lParam mask. // TODO: Add your control notification handler code here HWND hWndOK; GetDlgItem(IDOK, &hWndOK); ::EnableWindow(hWndOK, TRUE); } void CEditKey::OnOK() { CString s; GetDlgItemText(IDC_EDIT_KEY, s); int i=s.GetLength(); while(i--) { if(i>15 || !isxdigit(s[i])) { AfxMessageBox("Not a valid 64-bit hex number"); return; } } CDialog::OnOK(); } BOOL CEditKey::OnInitDialog() { CDialog::OnInitDialog(); HWND hWndOK; GetDlgItem(IDOK, &hWndOK);; ::EnableWindow(hWndOK, FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }