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

📄 property.cpp

📁 消息框大全
💻 CPP
字号:
// property.cpp : implementation file
//

#include "stdafx.h"
#include "MessageBoxes.h"
#include "property.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPageSimple property page

IMPLEMENT_DYNCREATE(CPageSimple, CPropertyPage)

CPageSimple::CPageSimple() : CPropertyPage(CPageSimple::IDD)
{
	//{{AFX_DATA_INIT(CPageSimple)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CPageSimple::~CPageSimple()
{
}

void CPageSimple::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPageSimple)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPageSimple, CPropertyPage)
	//{{AFX_MSG_MAP(CPageSimple)
	ON_BN_CLICKED(IDC_SIMPLEST_BTN, OnSimplestBtn)
	ON_BN_CLICKED(IDC_SIMPLE_BTN, OnSimpleBtn)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPageSimple message handlers
/////////////////////////////////////////////////////////////////////////////
// CPageOption property page

IMPLEMENT_DYNCREATE(CPageOption, CPropertyPage)

CPageOption::CPageOption() : CPropertyPage(CPageOption::IDD)
{
	//{{AFX_DATA_INIT(CPageOption)
	m_Message = _T("");
	//}}AFX_DATA_INIT
}

CPageOption::~CPageOption()
{
}

void CPageOption::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPageOption)
	DDX_Text(pDX, IDC_MESSAGE, m_Message);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPageOption, CPropertyPage)
	//{{AFX_MSG_MAP(CPageOption)
	ON_BN_CLICKED(IDC_OK_BTN, OnOkBtn)
	ON_BN_CLICKED(IDC_OKCANCEL_BTN, OnOkcancelBtn)
	ON_BN_CLICKED(IDC_YESNO_BTN, OnYesnoBtn)
	ON_BN_CLICKED(IDC_YESNOCANCEL_BTN, OnYesnocancelBtn)
	ON_BN_CLICKED(IDC_RETRYCANCEL_BTN, OnRetrycancelBtn)
	ON_BN_CLICKED(IDC_ABORTRETRYIGNORE_BTN, OnAbortretryignoreBtn)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPageOption message handlers
/////////////////////////////////////////////////////////////////////////////
// CPageCustom property page

IMPLEMENT_DYNCREATE(CPageCustom, CPropertyPage)

CPageCustom::CPageCustom() : CPropertyPage(CPageCustom::IDD)
{
	//{{AFX_DATA_INIT(CPageCustom)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CPageCustom::~CPageCustom()
{
}

void CPageCustom::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPageCustom)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPageCustom, CPropertyPage)
	//{{AFX_MSG_MAP(CPageCustom)
	ON_BN_CLICKED(IDC_SECONDDEFAULT_BTN, OnSeconddefaultBtn)
	ON_BN_CLICKED(IDC_THIRDDEFAULT_BTN, OnThirddefaultBtn)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPageCustom message handlers

void CPageSimple::OnSimplestBtn() 
{
	MessageBox("这是最最简单的消息框");		
}

void CPageSimple::OnSimpleBtn() 
{
	AfxMessageBox("另一个简单的消息框");		
}

void CPageOption::OnOkBtn() 
{
	MessageBox("仅仅一个按钮确定的消息框",
      "信息提示消息框",
      MB_OK|MB_ICONINFORMATION);

    m_Message = "你只是确认了一下";
    UpdateData(FALSE);
}

void CPageOption::OnOkcancelBtn() 
{
	int Response;

    Response =
    MessageBox("在这个消息框中你可以选择确定和取消"
      "\n\n你也可以在此写下对行信息文本"
      "\n这是你的权利",
      "选择消息框",
      MB_OKCANCEL|MB_ICONASTERISK);

    if( Response == IDOK )
    {
      m_Message = "你选择了确定";
      UpdateData(FALSE);
    }
    else
    {
      m_Message = "你取消了";
      UpdateData(FALSE);
    }
}

void CPageOption::OnYesnoBtn() 
{
	int Response;
  
	Response =
		MessageBox("你吃过了吗?我意思是指从昨天到现今",
		"信息提示", MB_YESNO|MB_ICONQUESTION);
    
  if( Response == IDYES )
  {
    m_Message = "那么,我不需要再给你什么了";
    UpdateData(FALSE);
  }
  else
  {
    m_Message = "那么走吧,正好我也没有吃,咱们一块去吃火锅!";
    UpdateData(FALSE);
  }
}

void CPageOption::OnYesnocancelBtn() 
{
	int Response;
    
    Response =
    MessageBox("当你删除一个目录的时候,或者一个文档改动后,"
	"\n退出程序的时候,这个消息框就会出现",
      "文档保存提示消息框",
      MB_YESNOCANCEL|MB_ICONWARNING);
      
    if( Response == IDYES )
    {
      m_Message = "执行操作.";
      UpdateData(FALSE);
    }
    else if( Response == IDNO )
    {
      m_Message = "不操作";
      UpdateData(FALSE);
    }
    else
    {
      m_Message = "取消";
      UpdateData(FALSE);
      }
}

void CPageOption::OnRetrycancelBtn() 
{
	int Response;
    
    Response =
    MessageBox("失败乃成功之母"
      "\n请Try吧:)",
      "重试提示消息框",
      MB_RETRYCANCEL|MB_ICONWARNING);

    if( Response == IDRETRY )
    {
      m_Message = "理所当然,重新来过!";
      UpdateData(FALSE);
    }
    else
    {
      m_Message = "你屈服了";
      UpdateData(FALSE);
    }
}

void CPageOption::OnAbortretryignoreBtn() 
{
	int Response;

    Response =
    MessageBox("这个就是最最令人厌恶的消息框了"
      "\n\n它的出现往往意味着程序出现了致命的错误,你不得不终止它,再次运行",
      "灾难消息框",
      MB_ABORTRETRYIGNORE|MB_ICONSTOP);

    if( Response == IDRETRY )
    {
      m_Message = "理所当然,重新来过!";
      UpdateData(FALSE);
    }
    else if( Response == IDIGNORE )
    {
      m_Message = "成大事者必不拘小姐";
      UpdateData(FALSE);
    }
    else
    {
      m_Message = "算你狠!";
      UpdateData(FALSE);
    }
}

void CPageCustom::OnSeconddefaultBtn() 
{
	int BtnClicked;

	BtnClicked = 
		MessageBox("注意看看默认按钮是否你需要的之后在回车不迟",
		"默认按钮消息框",
		MB_YESNOCANCEL|MB_ICONINFORMATION|MB_DEFBUTTON2);

	if( BtnClicked == IDYES )
		MessageBox("你按下了第一个按钮: 是");
	else if( BtnClicked == IDNO )
		MessageBox("你按下了第二个按钮: 否 即你接受了默认选择.");
	else
		MessageBox("你按下了第三个按钮: 取消");	
}

void CPageCustom::OnThirddefaultBtn() 
{
	int BtnClicked;

	BtnClicked = 
		MessageBox("注意看看默认按钮是否你需要的之后在回车不迟",
		"默认按钮消息框",
		MB_ABORTRETRYIGNORE|MB_ICONSTOP|MB_DEFBUTTON3);

	if( BtnClicked == IDABORT )
		MessageBox("你按下了第一个按钮: ABORT");
	else if( BtnClicked == IDRETRY )
		MessageBox("你按下了第二个按钮: RETRY");
	else
		MessageBox("你忽略了错误即你情愿接受默认选择");	
}

⌨️ 快捷键说明

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