我想显示一个对话框 用时间控制 比如只显示10秒 怎么控制???

ponydph 2004-11-30 11:15:34
如题.
比如程序启动之后,控制显示时间,然后消失 怎么实现/
...全文
94 点赞 收藏 12
写回复
12 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
960379 2004-12-01
程序中任何想控制已知精确时间都可以如此实现;如果要停留的时间不知道,则可以将sleep函数改为你想在对话框显示期间执行的操作。如果要倒计时,则需要在对话框上用timer实现。
回复
960379 2004-12-01
CSplashScreen* splash;
splash = new CSplashScreen;
splash->Create(CSplashScreen::IDD);
splash->SetIcon(hIcon,FALSE);
splash->SetWindowText("整定系统");
splash->ShowWindow(SW_SHOW);
splash->UpdateWindow();
Sleep(3000);
splash->ShowWindow(SW_HIDE);
splash->DestroyWindow();
delete splash;
回复
loki2k 2004-12-01
倒记时简单啊,首先用一个Timer吧,时间用秒做基本单位,设定多久触发一次,时间然后递减,显示的时候把秒转换一下,到0就KillTimer(),OnCancel(),
回复
sinall 2004-12-01
使用定时器
SetTimer
OnTimer里计时,判断
回复
captainwh 2004-12-01
#include <windows.h>
#include <stdio.h>

int main()
{
HANDLE hTimer = NULL;
LARGE_INTEGER liDueTime;

liDueTime.QuadPart=-100000000;

// Create a waitable timer.
hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer");
if (!hTimer)
{
printf("CreateWaitableTimer failed (%d)\n", GetLastError());
return 1;
}

printf("Waiting for 10 seconds...\n");

// Set a timer to wait for 10 seconds.
if (!SetWaitableTimer(
hTimer, &liDueTime, 0, NULL, NULL, 0))
{
printf("SetWaitableTimer failed (%d)\n", GetLastError());
return 2;
}

// Wait for the timer.

if (WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0)
printf("WaitForSingleObject failed (%d)\n", GetLastError());
else printf("Timer was signaled.\n");

return 0;
}
回复
captainwh 2004-12-01
#include <windows.h>
#include <stdio.h>

int main()
{
HANDLE hTimer = NULL;
LARGE_INTEGER liDueTime;

liDueTime.QuadPart=-100000000;

// Create a waitable timer.
hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer");
if (!hTimer)
{
printf("CreateWaitableTimer failed (%d)\n", GetLastError());
return 1;
}

printf("Waiting for 10 seconds...\n");

// Set a timer to wait for 10 seconds.
if (!SetWaitableTimer(
hTimer, &liDueTime, 0, NULL, NULL, 0))
{
printf("SetWaitableTimer failed (%d)\n", GetLastError());
return 2;
}

// Wait for the timer.

if (WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0)
printf("WaitForSingleObject failed (%d)\n", GetLastError());
else printf("Timer was signaled.\n");

return 0;
}
回复
captainwh 2004-12-01
#include <windows.h>
#include <stdio.h>

int main()
{
HANDLE hTimer = NULL;
LARGE_INTEGER liDueTime;

liDueTime.QuadPart=-100000000;

// Create a waitable timer.
hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer");
if (!hTimer)
{
printf("CreateWaitableTimer failed (%d)\n", GetLastError());
return 1;
}

printf("Waiting for 10 seconds...\n");

// Set a timer to wait for 10 seconds.
if (!SetWaitableTimer(
hTimer, &liDueTime, 0, NULL, NULL, 0))
{
printf("SetWaitableTimer failed (%d)\n", GetLastError());
return 2;
}

// Wait for the timer.

if (WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0)
printf("WaitForSingleObject failed (%d)\n", GetLastError());
else
printf("Timer was signaled.\n");

return 0;
}
回复
ponydph 2004-12-01
多谢各位
回复
ponydph 2004-11-30
CreateWaitableTimer怎么使用?
设置定时器倒是挺好,要想实现在对话框上显示倒计时 就更好了
回复
社会栋梁 2004-11-30
初始SetTimer(1,10000,NULL)
在ONTIMER中,killtimer()
回复
qrlvls 2004-11-30
比较简单的方法,在对话框的OnInitDialog中SetTimer,在OnTimer中OnOK
回复
flyelf 2004-11-30
CreateWaitableTimer
回复
相关推荐
发帖
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
帖子事件
创建了帖子
2004-11-30 11:15
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……