博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C++ MessageBox()
阅读量:6892 次
发布时间:2019-06-27

本文共 2115 字,大约阅读时间需要 7 分钟。

关于MessageBox function,参考:

更多示例,参考Using Dialog Boxes()

 

 

IDE: Code::Blocks 16.01

操作系统:Windows 7 x64

1 #include 
2 #include
3 4 /* In the following example, the application displays a message box 5 that prompts the user for an action after an error condition has occurred. 6 The message box displays the message that describes the error condition 7 and how to resolve it. 8 The MB_YESNO style directs MessageBox to provide two buttons 9 with which the user can choose how to proceed : */10 int DisplayConfirmSaveAsMessageBox()11 {12 int msgboxID = MessageBox(13 NULL,14 "temp.txt already exists.\nDo you want to replace it?",15 "Confirm Save As",16 MB_ICONEXCLAMATION | MB_YESNO17 );18 19 if (msgboxID == IDYES)20 {21 // TODO: add code22 }23 24 return msgboxID;25 }26 27 int _cdecl _tmain()28 {29 DisplayConfirmSaveAsMessageBox();30 31 return 0;32 }

 

在Code::Blocks 16.01中的运行结果:

 

 

IDE: Microsoft Visual Studio Community 2017 15.5.2

操作系统:Windows 7 x64

1 #include "stdafx.h" 2  3 #include 
4 5 /* In the following example, the application displays a message box 6 that prompts the user for an action after an error condition has occurred. 7 The message box displays the message that describes the error condition 8 and how to resolve it. 9 The MB_YESNO style directs MessageBox to provide two buttons 10 with which the user can choose how to proceed : */11 int DisplayConfirmSaveAsMessageBox()12 {13 int msgboxID = MessageBox(14 NULL,15 L"temp.txt already exists.\nDo you want to replace it?",16 L"Confirm Save As",17 MB_ICONEXCLAMATION | MB_YESNO18 );19 20 if (msgboxID == IDYES)21 {22 // TODO: add code23 }24 25 return msgboxID;26 }27 28 int _cdecl _tmain()29 {30 DisplayConfirmSaveAsMessageBox();31 32 return 0;33 }

 

在Microsoft Visual Studio Community 2017 15.5.2中的运行结果:

 


 

 

 关于MessageBox()的参数:

第一个,不太理解。

第二个,指定要显示的文本信息。

第三个,指定消息框的标题。

第四个,指定图标,及按键等等。

转载于:https://www.cnblogs.com/Satu/p/8214133.html

你可能感兴趣的文章
自定义ANDROID中EDITTEXT中的HINT文本的大小
查看>>
Unity3D下用C#通过WinSCP命令行方式给Linux服务器SCP传文件
查看>>
Fedora遇难记之rpmfusion:获取 GPG 密钥失败
查看>>
Exception
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
VC改变鼠标的WM_SETCURSOR( setcursor() )
查看>>
jQuery添加/改变/移除CSS类及判断是否已经存在CSS
查看>>
Leetcode PHP题解--D82 13. Roman to Integer
查看>>
使用scrapy抓取股票代码
查看>>
hashmap实现原理浅析
查看>>
1.1什么是数据仓库
查看>>
注册个博客好累哦
查看>>
spring mvc 如何从前台表单传递集合参数并绑定集合对象
查看>>
编程实现strcpy函数功能
查看>>
网络红人魏道道:做微商的不知道就真的“out”了
查看>>
PHP关于时间的时段的重合、 整合的方法
查看>>
awk sed grep 正则表达式
查看>>
Python学习第七天
查看>>
MySQL 分析服务器状态
查看>>