Need help with form timer

  • Thread starter Thread starter aprivate
  • Start date Start date
A

aprivate

Hi
I am having some problem with a form timer.

I added a progress bar to increment its value and
the timer works when I use form1.showdialog()

However when I use form1.show, form1.refresh()
the timer does not fire even if I had explicitly
set the timer1.enabled=true and timer1.start


What I want to do:

All I want to do is to have a form that can detach itself from
the calling subroutine, so that I can show some kind of progress
message as I am checking for some file elsewhere.

Thanks
Allan
 
aprivate said:
Hi
I am having some problem with a form timer.

I added a progress bar to increment its value and
the timer works when I use form1.showdialog()

However when I use form1.show, form1.refresh()
the timer does not fire even if I had explicitly
set the timer1.enabled=true and timer1.start


What I want to do:

All I want to do is to have a form that can detach itself from
the calling subroutine, so that I can show some kind of progress
message as I am checking for some file elsewhere.


If you use Show instead of Showdialog, perhaps you are executing code after
calling Show. Is this right? During the execution, the Timer does not fire.

Armin
 
Hi
Yes, I wanted the timer to fire so that it can change some color on the
screen to
tell the user the program is not hung.

Is there a better way to do this kind of status report?

Regds
Allan
 
aprivate said:
Hi
Yes, I wanted the timer to fire so that it can change some color on
the screen to
tell the user the program is not hung.

Is there a better way to do this kind of status report?

Either: Execute the code in a seperate thread. You're main thread will be
responding and be able to process timer messages.

Or: Raise an event from the running code (e.g. within a loop). Catch the
event in the Form and update the display if necessary. Attention: Due to a
"feature" in WinXP, even forcing the display to update by calling a
control's refresh method does not work anymore! See 3rd paragraph here:

http://msdn.microsoft.com/library/e...ssagequeues/aboutmessagesandmessagequeues.asp

Luckily there is a work-around: Call PeekMessage API function when handling
the event.


Multithreading example - actually showing a splash screen but you'll see the
point:

http://people.freenet.de/armin.zingler/NGMultithreadedSplash.zip


Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top