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

📄 editdlg.cpp

📁 Visual_C++[1].NET_Bible1 Visual_C++宝典书中的全部源码
💻 CPP
字号:
// EditDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ControlsDemo.h"
#include "EditDlg.h"


// CEditDlg dialog

IMPLEMENT_DYNAMIC(CEditDlg, CDialog)
CEditDlg::CEditDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CEditDlg::IDD, pParent)
  , m_strTo(L"")
  , m_nCopies(0)
  , m_strBookTitle(_T(""))
  , m_strPassword(_T(""))
  , m_strLetter(_T(""))
  , m_iTitle(0)
{
}

CEditDlg::~CEditDlg()
{
}

void CEditDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
  DDX_Text(pDX, IDC_EDIT1, m_strTo);
  DDX_Text(pDX, IDC_EDIT2, m_nCopies);
  DDX_Text(pDX, IDC_EDIT3, m_strBookTitle);
  DDX_Text(pDX, IDC_EDIT4, m_strPassword);
  DDX_Text(pDX, IDC_EDIT5, m_strLetter);
  DDX_Radio(pDX, IDC_RADIO1, m_iTitle);
}


BEGIN_MESSAGE_MAP(CEditDlg, CDialog)
  ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()


// CEditDlg message handlers

void CEditDlg::OnBnClickedOk()
{
  if (UpdateData())
  {
    if (0 < m_strTo.GetLength()
    && 0 < m_strBookTitle.GetLength()
    && 0 < m_nCopies
    && 0 < m_strPassword.GetLength())
    {
      CString strTitle;
      GetTitle(strTitle);

      m_strLetter.Format("Dear %s %s,"
        "\r\n\r\n"
        "\tAs my way of saying thanks for the great job in helping "
        "me write this book, I am sending you %ld copies of the book, "
        "'%s'.\r\n"
        "\tThis book does include a password protected site where "
        "you can download all source code. Your password is '%s'."
        "\r\n\r\nSincerely,\r\nTom Archer",
        strTitle, m_strTo,
        m_nCopies, m_strBookTitle,
        m_strPassword);
      UpdateData(FALSE);
    }
    else
    {
      AfxMessageBox("You must enter all values");
    }
  }
}

void CEditDlg::GetTitle(CString& strTitle)
{
  CWnd* pWnd = NULL;

  switch (m_iTitle)
  {
    case 0: 
      pWnd = GetDlgItem(IDC_RADIO1);
      break;
    case 1: 
      pWnd = GetDlgItem(IDC_RADIO2);
      break;
    case 2: 
      pWnd = GetDlgItem(IDC_RADIO3);
      break;
    default: ASSERT(FALSE);
  }

  ASSERT(pWnd);
  if (pWnd)
  {
    pWnd->GetWindowText(strTitle);
  }
}

⌨️ 快捷键说明

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