如何实现????
解决方案 »
- mfc实现客户端和服务器端的数据传输?
- 如何在显示的位图上截取一矩形区域 双击选择的矩形区域 弹出对话框 并将截取的位图显示在对话框上
- ListView上实现ToolTip怎么ToolTip一闪就没掉了
- 关于数据库的学习,大家来给点意见,顺便散点分。。。。
- 堆栈中 KERNEL32.dll+0x289a5 ,后面的16进制数字代表什么意思
- 关于stmp邮件发送客户端的问题
- 关于兼容性问题
- 请问怎么在edit控键中画一个方块图
- CInternetSession OpenURl问题
- 关于动态生成的CButton对象的消息处理的问题
- \u5979这是什么代码,怎么转成中文
- 关于hook com,还差一点就成功了!
OnTimer里
SendMessage(WM_CLOSE)
/******************************************************************************
Module: TimedMsgBox.cpp
Notices: Copyright (c) 2000 Jeffrey Richter
******************************************************************************/
#include "..\CmnHdr.h" /* See Appendix A. */
#include <tchar.h>
//////////////////////////////////////////////////////////////////////////////
// The caption of our message box
TCHAR g_szCaption[] = TEXT("Timed Message Box");
// How many seconds we'll display the message box
int g_nSecLeft = 0;
// This is STATIC window control ID for a message box
#define ID_MSGBOX_STATIC_TEXT 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); 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--);
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.
}
}
//////////////////////////////////////////////////////////////////////////////
int WINAPI _tWinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int) { chWindows9xNotAllowed(); // How many seconds we'll give the user to respond
g_nSecLeft = 10; // Create a multishot 1 second timer that begins firing after 1 second.
HANDLE hTimerQTimer;
CreateTimerQueueTimer(&hTimerQTimer, NULL, MsgBoxTimeout, NULL,
1000, 1000, 0); // Display the message box
MessageBox(NULL, TEXT("You have 10 seconds to respond"),
g_szCaption, MB_OK); // Cancel the timer & delete the timer queue
DeleteTimerQueueTimer(NULL, hTimerQTimer, NULL); // Let us know if the user responded or if we timed-out.
MessageBox(NULL,
(g_nSecLeft == 0) ? TEXT("Timeout") : TEXT("User responded"),
TEXT("Result"), MB_OK); return(0);
}
//////////////////////////////// End of File /////////////////////////////////
来自windows核心编程的东西
期待你会喜欢:-)
SendMessage(WM_CLOSE);
http://www.codeproject.com/KB/dialog/delaymessagebox.aspx