楼上的做过测试没有,不要误人子弟。 以下是《Windows 核心编程》动态更改提示框内容的函数。// 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. } }
AfxMessageBox("要提示的信息");
我只会这2种了
试着用GetWindow得到它的有文本的STATIC
以下是《Windows 核心编程》动态更改提示框内容的函数。// 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.
}
}
4楼的谢谢你了。但不是我要的答案。我是想获得提示文本,而不是修改提示文本
3楼能具体讲讲GetWindow()函数么,谢谢了
替换成
GetDlgItemText(hwnd,ID_MSGBOX_STATIC_TEXT,sz,100);//测试代码,能正确获得提示框内容
/////////////////////////////////////////////
这不就是获得对话框的函数吗
// This is STATIC window control ID for a message box
#define ID_MSGBOX_STATIC_TEXT 0x0000ffff//提示框的ID为固定的 0x0000ffff