浅谈弹出对话框 -- MessageBox

· · 个人记录

消息框中返回一个整数值,该值指示用户单击了哪个按钮。
```cpp MessageBox(NULL,"正文","标题",T | Q); //记得NULL ``` 其中 $\texttt T$ 代表按钮属性(弹出哪些按钮),默认为 $\texttt{MB\_OK}$,所有的如下表: ![](https://cdn.luogu.com.cn/upload/image_hosting/w7rm5460.png) 其中 $\texttt Q$ 代表图标属性(弹出的图标样式),默认为 $\texttt{MB\_OK}$,所有的如下表: ![](https://cdn.luogu.com.cn/upload/image_hosting/7ykezrm5.png) *** 我们可以用 $\mathtt{if}$ 语句判断用户按了什么按钮。 用户按了什么按钮,就是函数返回值。 ![](https://cdn.luogu.com.cn/upload/image_hosting/rbhb4wqk.png) 例子: ```cpp #include<windows.h> //qaq #include<iostream> using namespace std; int main() { bool qaq=false; while (MessageBox(NULL,"快点YES","看下面",MB_ICONWARNING|MB_YESNO)!=IDYES) MessageBox(NULL,"明明叫你点YES啊","这里是标题qaq",MB_OK),qaq=true; if (qaq) MessageBox(NULL,"终于点YES啦(*^▽^*)","开心",MB_OK); else MessageBox(NULL,"感谢您的支持哦!o(* ̄▽ ̄*)o","感谢支持!",MB_OK); return 0; } ```