| Код | // FrandbergDlg.cpp : implementation file //
#include "stdafx.h" #include "Frandberg.h" #include "FrandbergDlg.h" #include "cgrapher.h"
#ifdef _DEBUG #define new DEBUG_NEW #endif
// CFrandbergDlg dialog
CFrandbergDlg::CFrandbergDlg(CWnd* pParent /*=NULL*/) : CDialog(CFrandbergDlg::IDD, pParent) , m_Message(_T("")) , m_VKey(0) , m_EKey(0) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_pEditBkBrush = new CBrush(RGB(255, 255, 255)); }
void CFrandbergDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Text(pDX, IDC_EDIT, m_Message); DDX_Text(pDX, IDC_VIEWKEY, m_VKey); DDX_Text(pDX, IDC_ENTKEY, m_EKey); }
BEGIN_MESSAGE_MAP(CFrandbergDlg, CDialog) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_WM_CTLCOLOR() ON_WM_DESTROY() //}}AFX_MSG_MAP // ON_BN_SETFOCUS(IDCANCEL, &CFrandbergDlg::OnBnSetfocusCancel) ON_BN_CLICKED(CIPHER, &CFrandbergDlg::OnBnClickedCipher) ON_BN_CLICKED(DECIPHER, &CFrandbergDlg::OnBnClickedDecipher) END_MESSAGE_MAP()
// CFrandbergDlg message handlers
BOOL CFrandbergDlg::OnInitDialog() { CDialog::OnInitDialog();
// 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
return TRUE; // return TRUE unless you set the focus to a control }
HBRUSH CFrandbergDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { switch (nCtlColor) { case CTLCOLOR_EDIT: case CTLCOLOR_MSGBOX: pDC->SetTextColor(RGB(255, 0, 0)); pDC->SetBkColor(RGB(255, 255, 255)); return (HBRUSH)(m_pEditBkBrush->GetSafeHandle());
default: return CDialog::OnCtlColor(pDC, pWnd, nCtlColor); } } void CFrandbergDlg::OnDestroy() { CDialog::OnDestroy(); delete m_pEditBkBrush; }
// If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework.
void CFrandbergDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } }
// The system calls this function to obtain the cursor to display while the user drags // the minimized window. HCURSOR CFrandbergDlg::OnQueryDragIcon() { return static_cast<HCURSOR>(m_hIcon); }
cgrapher object;
void CFrandbergDlg::OnBnClickedCipher() { UpdateData(TRUE); object.enter_message(m_Message); object.rand_key(); object.to_cipher(); m_Message = object.view_message(); m_VKey = object.view_key(); GetDlgItem(CIPHER) -> EnableWindow(FALSE); GetDlgItem(IDC_EDIT) -> EnableWindow(FALSE); GetDlgItem(DECIPHER) -> EnableWindow(TRUE); GetDlgItem(IDC_ENTKEY) -> EnableWindow(TRUE); UpdateData(FALSE); }
void CFrandbergDlg::OnBnClickedDecipher() { UpdateData(TRUE); object.enter_key(m_EKey); UpdateData(FALSE); }
|
Но когда элемент (поле) disabled, цвет меняется на серый. Как этого избежать? |