VC 定时 messagebox 消息框
来源:互联网 发布:java并发编程实战pdf 编辑:程序博客网 时间:2024/05/20 11:27
HWND g_hwndTimedOwner = 0;
BOOL g_bTimedOut = 0;
void CALLBACK MessageBoxTimer(HWND hwnd,
UINT uiMsg,
UINT idEvent,
DWORD dwTime)
{
g_bTimedOut = TRUE;
if (g_hwndTimedOwner)
EnableWindow(g_hwndTimedOwner, TRUE);
PostQuitMessage(0);
}
int TimedMessageBox(HWND hwndOwner,
LPCTSTR pszMessage,
LPCTSTR pszTitle,
UINT flags,
DWORD dwTimeout)
{
UINT idTimer;
int iResult;
g_hwndTimedOwner = NULL;
g_bTimedOut = FALSE;
if (hwndOwner && IsWindowEnabled(hwndOwner))
g_hwndTimedOwner = hwndOwner;
// Set a timer to dismiss the message box.
idTimer = SetTimer(NULL, 0, dwTimeout, (TIMERPROC)MessageBoxTimer);
iResult = MessageBox(hwndOwner, pszMessage, pszTitle, flags);
// Finished with the timer.
KillTimer(NULL, idTimer);
// See if there is a WM_QUIT message in the queue if we timed out.
// Eat the message so we do not quit the whole application.
if (g_bTimedOut)
{
MSG msg;
PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE);
iResult = -1;
}
return iResult;
BOOL g_bTimedOut = 0;
void CALLBACK MessageBoxTimer(HWND hwnd,
UINT uiMsg,
UINT idEvent,
DWORD dwTime)
{
g_bTimedOut = TRUE;
if (g_hwndTimedOwner)
EnableWindow(g_hwndTimedOwner, TRUE);
PostQuitMessage(0);
}
int TimedMessageBox(HWND hwndOwner,
LPCTSTR pszMessage,
LPCTSTR pszTitle,
UINT flags,
DWORD dwTimeout)
{
UINT idTimer;
int iResult;
g_hwndTimedOwner = NULL;
g_bTimedOut = FALSE;
if (hwndOwner && IsWindowEnabled(hwndOwner))
g_hwndTimedOwner = hwndOwner;
// Set a timer to dismiss the message box.
idTimer = SetTimer(NULL, 0, dwTimeout, (TIMERPROC)MessageBoxTimer);
iResult = MessageBox(hwndOwner, pszMessage, pszTitle, flags);
// Finished with the timer.
KillTimer(NULL, idTimer);
// See if there is a WM_QUIT message in the queue if we timed out.
// Eat the message so we do not quit the whole application.
if (g_bTimedOut)
{
MSG msg;
PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE);
iResult = -1;
}
return iResult;
}
用法:
TimedMessageBox( theApp.m_pMainWnd->m_hWnd, CString("设置2000毫秒显示,然后自动关闭"), _T("消息框标题"), MB_OK, 2000 );
0 0
- VC 定时 messagebox 消息框
- 定时发消息终止退出MessageBox弹框 .
- VC创建定时关闭的MessageBox
- VC 定时自动关闭MessageBox弹出对话框
- MessageBox 消息框
- Ext.MessageBox消息框
- 消息框MessageBox
- wpf MessageBox 消息框
- Ext.MessageBox消息框
- C#_ACCP_Windows_消息框MessageBox
- VC中MessageBox消息对话框的使用方法总结
- 消息框函数: AfxMessageBox 和 MessageBox
- C++ Windows应用程序 弹出消息框MessageBox
- python中弹出消息框--MessageBox
- C#学习_消息框MessageBox
- [windows程序设计]-消息弹框,messagebox---ShinePans
- 详解C#中MessageBox消息框
- 关于MessageBox消息弹出框的制作
- sqlserver排序规则&小数位精度不能自动截断的异常
- PostgreSQL学习笔记3之表的继承和分区
- 在DLL中使用duilib,并把ZIP皮肤编译进DLL中
- 常用的mysql语句
- Stanford机器学习课程(Andrew Ng) Week 1 Parameter Learning --- 线性回归中的梯度下降法
- VC 定时 messagebox 消息框
- POJ1979 DFS
- <C++ primer plus>学习笔记
- 解决【高清屏幕显示模糊】的问题
- 首款中文渗透测试专用Linux系统—MagicBoxf
- 一个IIC的5V和3.3V电平转换的经典电路分享
- 前端mock数据
- 程序员的进步直接取决于自身行为
- Scheme白名单问题(无法判断手机是否安装微信等)