call set timer in dialog init 
Author Message
 call set timer in dialog init

In my Dialog base app , it call a function in OnInitDialog before it return,
in the function, there is set timer , but i found in OnTimer , my app
crash when call CDialog::OnTimer(nIDEvent);

--
Daniel Wang
Bijitec Pte Ltd
Tel: (86) 21 6432 5854 ext 808 (Shanghai)



Tue, 26 Apr 2005 09:45:55 GMT  
 call set timer in dialog init
Strange.
How do you use your timer?
Usually it goes like:
void CMainFrame::OnInitDialog()
{
  m_nTimer = SetTimer(1, 2000, 0);

Quote:
}

void CMainFrame::OnStopTimer()
{
  KillTimer(m_nTimer);

Quote:
}

void CMainFrame::OnTimer(UINT nIDEvent)
{
  MessageBeep(0xFFFFFFFF);  // Beep

  // Call base class handler.
  CMDIFrameWnd::OnTimer(nIDEvent);

Quote:
}



Quote:
> In my Dialog base app , it call a function in OnInitDialog before it
return,
> in the function, there is set timer , but i found in OnTimer , my app
> crash when call CDialog::OnTimer(nIDEvent);

> --
> Daniel Wang
> Bijitec Pte Ltd
> Tel: (86) 21 6432 5854 ext 808 (Shanghai)



Tue, 26 Apr 2005 16:55:05 GMT  
 call set timer in dialog init
In fact, i found CDialog's OnTimer function can not be call before
OnInitDialog  return.

for example, my function A will can set timer.
and i put Function A in OnInitDialog  before return TRYE/FALSE, it will
crash.
now i have to use another set timer to instead. wait after init return, then
in Dialog ontimer, put the function A in it.



Quote:
> Strange.
> How do you use your timer?
> Usually it goes like:
> void CMainFrame::OnInitDialog()
> {
>   m_nTimer = SetTimer(1, 2000, 0);
> }

> void CMainFrame::OnStopTimer()
> {
>   KillTimer(m_nTimer);
> }

> void CMainFrame::OnTimer(UINT nIDEvent)
> {
>   MessageBeep(0xFFFFFFFF);  // Beep

>   // Call base class handler.
>   CMDIFrameWnd::OnTimer(nIDEvent);
> }



> > In my Dialog base app , it call a function in OnInitDialog before it
> return,
> > in the function, there is set timer , but i found in OnTimer , my app
> > crash when call CDialog::OnTimer(nIDEvent);

> > --
> > Daniel Wang
> > Bijitec Pte Ltd
> > Tel: (86) 21 6432 5854 ext 808 (Shanghai)



Fri, 29 Apr 2005 03:18:38 GMT  
 call set timer in dialog init
You also have to carefully define "crash". It is an unintelligible description. Did you
get an access fault, an assert failure, or what? What function did it crash in? What was
it trying to do? Without critical information like this it is absolutely impossible to
analyze a problem. I call SetTimer in OnInitDialog all the time and have never had a
problem with the timer. However, if you are calling a timer function before you exit
OnInitDialog, you have to show exactly how you are calling it and what it is doing. If you
are calling a timer from OnInitDialog and also call it from OnTimer, it is critical to
determine what it was trying to do at the time the problem occurred.
                                        joe

Quote:

>In fact, i found CDialog's OnTimer function can not be call before
>OnInitDialog  return.

>for example, my function A will can set timer.
>and i put Function A in OnInitDialog  before return TRYE/FALSE, it will
>crash.
>now i have to use another set timer to instead. wait after init return, then
>in Dialog ontimer, put the function A in it.



>> Strange.
>> How do you use your timer?
>> Usually it goes like:
>> void CMainFrame::OnInitDialog()
>> {
>>   m_nTimer = SetTimer(1, 2000, 0);
>> }

>> void CMainFrame::OnStopTimer()
>> {
>>   KillTimer(m_nTimer);
>> }

>> void CMainFrame::OnTimer(UINT nIDEvent)
>> {
>>   MessageBeep(0xFFFFFFFF);  // Beep

>>   // Call base class handler.
>>   CMDIFrameWnd::OnTimer(nIDEvent);
>> }



>> > In my Dialog base app , it call a function in OnInitDialog before it
>> return,
>> > in the function, there is set timer , but i found in OnTimer , my app
>> > crash when call CDialog::OnTimer(nIDEvent);

>> > --
>> > Daniel Wang
>> > Bijitec Pte Ltd
>> > Tel: (86) 21 6432 5854 ext 808 (Shanghai)

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Tue, 10 May 2005 02:45:35 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Radio Button Init - how do I set it

2. CGI in Perl calling C functions: env variable init issue

3. ATL Thread init code - calling srand

4. Timers, Timers, Timers...

5. System.Timers.Timer & System.threading.Timer

6. Where can I Init a Dialog

7. init a dialog without popping up the template

8. Stupid question - check boxes state on init dialog....

9. Warning: CreateDlgControls failed during dialog init.

10. Drawing in a static control at dialog init - the answer

11. Init dialog to position

12. dialog box init position?

 

 
Powered by phpBB® Forum Software