16,472
社区成员
发帖
与我相关
我的任务
分享
// This is STATIC window control ID for a message box
#define ID_MSGBOX_STATIC_TEXT 0x0000ffff//提示框的ID为固定的 0x0000ffff
//////////////////////////////////////////////////////////////////////////////
VOID WINAPI MsgBoxTimeout(PVOID pvContext, BOOLEAN fTimeout) {
// NOTE: Due to a thread race condition, it is possible (but very unlikely)
// that the message box will not be created when we get here.
HWND hwnd = FindWindow(NULL, g_szCaption);//g_szCaption对话框标题
if (hwnd != NULL) {
// The window does exist; update the time remaining.
TCHAR sz[100];
wsprintf(sz, TEXT("You have %d seconds to respond"), g_nSecLeft--);
//GetDlgItemText(hwnd,ID_MSGBOX_STATIC_TEXT,sz,100);//测试代码,能正确获得提示框内容
SetDlgItemText(hwnd, ID_MSGBOX_STATIC_TEXT, sz);
if (g_nSecLeft == 0) {
// The time is up; force the message box to exit.
EndDialog(hwnd, IDOK);
}
} else {
// The window does not exist yet; do nothing this time.
// We'll try again in another second.
}
}