定时消失的对话框API函数 -- MessageBoxTimeout

来源:互联网 发布:sql server 教程 高级 编辑:程序博客网 时间:2024/05/18 01:30

我们在微软官方文档上找不到MessageBoxTimeout()的记录,它是由user32.dll导出的。
使用时只需在.cpp文件中包含了以下部分,就可以调用MessageBoxTimeout。

// 添加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

需要指出的是,Windows 2000的user32.dll没有导出这个函数。

// 设置1000ms自动关闭该提示对话框MessageBoxTimeout(NULL, L"倒计时", L"提示", MB_OKCANCEL, 0, 1000);
0 0
原创粉丝点击