//
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
/********************************/
// Code By
/********************************/
HHOOK hook=NULL;
int MSGRET=0;
int k=0;
HWND MSGHWND,TEXTHWND;
UINT TD;
void CALLBACK TimerProc(
HWND hwnd,
UINT uMsg,
UINT idEvent,
DWORD dwTime )
{
if (k==0)
{
k=5;
SendMessageA(MSGHWND,WM_COMMAND,6,0);
}else
{
k--;
char title[100]={0};
sprintf(title,"退出时间还剩: %d 秒",k);
SetWindowText(TEXTHWND,title);
}
}
LRESULT CALLBACK CBTProc(
int nCode, // hook code
WPARAM wParam, // depends on hook code
LPARAM lParam // depends on hook code
)
{
if (nCode==WH_CBT)
{
UnhookWindowsHookEx(hook);
k=5;
MSGHWND=(HWND)wParam;
TEXTHWND=GetDlgItem(MSGHWND,65535);
TD=SetTimer(0,1,1000,(TIMERPROC)TimerProc);
}
return 0;
}
void main()
{
hook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTProc,GetModuleHandle(NULL),0);
MSGRET=MessageBox(NULL,"退出时间还剩: 5 秒","提示信息:",0x40);
//MSGRET 用来确定你单击的是哪个按钮
MSG msg;
while (GetMessage(&msg,NULL,NULL,NULL))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
自动的关闭对话框 MessageBox
转载
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
TCP关闭连接的方式tcp
-
自动关闭对话框
<br />{*******************************************************}{ }{ 一种自动关闭对话框的简单方法
integer application forms function div -
MFC实例:[3] MessageBox消息对话框
MessageBox消息对话框
控件 程序代码 退出程序