MessageBox弹窗函数
MessageBox(NULL,"窗口内容","窗口标题",按钮类型|图标);
按钮样式:
MB_OK 确定
MB_OKCANCEL 确定和取消
MB_YESNO 是和否
MB_RETRYCANCEL 重试和取消
MB_ABORTRETRYIGNORE: 中止、重试和忽略
MB_YESNOCANCEL 是、否和取消
图标:
MB_ICONEXCLAMATION 警告图标
MB_ICONHAND 红叉图标
MB_ICONQUESTION 问号图标
MB_ICONASTERISK 倒叹号图标
返回值:
IDYES 选中是按钮
IDNO 选中否按钮
IDOK 选中确定按钮
IDCANCEL 选中取消按钮
IDABORT 选中中止按钮
IDIGNORE 选中忽略按钮
IDRETRY 选中重试按钮
示例代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
switch(MessageBox(NULL,"窗口内容","窗口标题",MB_ABORTRETRYIGNORE|MB_ICONHAND)){
case IDABORT:cout<<"选中终止"<<endl;
case IDRETRY:cout<<"选中重试"<<endl;
case IDIGNORE:cout<<"选中忽略"<<endl;
}
}
system函数
system("命令");
这里列几个常用命令:
shutdown -p 立刻关机
shutdown -r 立刻重启
taskkill /f /t /im 进程名 结束进程
title 标题 更改标题
Sleep函数
Sleep(毫秒);
等待
MessageBoxTimeout弹窗函数
添加支持:
extern "C"{
int WINAPI MessageBoxTimeoutA(IN HWND hWnd, IN LPCSTR lpText, IN LPCSTR lpCaption, IN UINT uType, IN WORD wLanguageId, IN DWORD dwMilliseconds);
int WINAPI MessageBoxTimeoutW(IN HWND hWnd, IN LPCWSTR lpText, IN LPCWSTR lpCaption, IN UINT uType, IN WORD wLanguageId, IN DWORD dwMilliseconds);
};
#ifdef UNICODE
#define MessageBoxTimeout MessageBoxTimeoutW
#else
#define MessageBoxTimeout MessageBoxTimeoutA
#endif
弹窗:
MessageBoxTimeout(NULL,"窗口内容","窗口标题",按钮类型|图标,0,时间);
记得点赞