Dialog :: OnTimer没有被调用 [英] Dialog::OnTimer is not getting called

查看:101
本文介绍了Dialog :: OnTimer没有被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在从相机进行流式传输,同时尝试在静态框上显示秒数.在单击按钮事件时,而(EventMsg.message!= WM_QUIT)我正在流式传输并显示来自相机的图像.显示我正在使用MFC计时器的秒数,并且在每1000ms上向窗口通知WM_TIMER时,应该调用CStreamDlg :: OnTimer(UINT nIDEvent)函数,但这没有发生.
我的CStreamDlg :: OnTimer(UINT nIDEvent)函数如下所示:

Hi,
I am streaming from a camera and at the same time I am trying to display the seconds on a static box.On a button click event, while(EventMsg.message != WM_QUIT) I am streaming and displaying the images from the camera.Now to display the seconds I am using MFC timers and when WM_TIMER is notified to window on each 1000ms my CStreamDlg::OnTimer(UINT nIDEvent) function is supposed to be called which is not happening.
My CStreamDlg::OnTimer(UINT nIDEvent) function looks like the following:

void CStreamDlg::OnTimer(UINT nIDEvent) {
    char msg[10];
    if(nIDEvent == ID_TIMER_SECOND){
        iSeconds+=1;
        sprintf_s(msg,10,"%d",iSeconds);
        ((CStatic*)GetDlgItem(IDC_STATIC_SECS))->SetWindowTextA(msg);
    }
}


在此先谢谢您


Thanks in advance

推荐答案

在OnTimer通话结束时,您应该输入
At the end of your OnTimer call you should put something like
CDialog::OnTimer(nIDEvent);



并且您应该使用
配置和启动计时器



And you should configure and start the timer using

m_nTimer = SetTimer (ID_TIMER_SECOND, 1000, 0);



而且不要忘了最后杀死计时器...



And don''t forget to kill the timer at the end...

Killtimer(m_nTimer);



希望这对您有帮助...:thumbsup:

PS:我确信SAKryukov的提案至少会很有趣,因此很高兴您看一下……同时,因为他建议使用线程来获得相同的行为,所以我不知道您是否习惯使用它们,或者即使您可以根据要求进行操作,这里也有经典的计时器方法...


两个很好地解释计时器的链接:

第一个来自 Nemanja Trifunovic [计时器教程 [其产品 [



Hope this helps... :thumbsup:

PS: I''m sure that the proposal from SAKryukov will be at least interesting so it would be nice for you to take a look at it... meanwhile, as he is suggesting to use threads to get the same behavior, and I don''t know if you are comfortable using them or not or even if you can do it from your requirements, here you have a classic timer approach...


Two links that explain timers in a nice way:

The first one is from Nemanja Trifunovic[^] and is a timers tutorial[^].

The second one is from a commercial company that will try to sell their product[^]... Anyway, you can get some extra information and numbers on the different type of timers out there...


这篇关于Dialog :: OnTimer没有被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆