Board index » delphi » Timer Ques ('Wait' Funtionality?)

Timer Ques ('Wait' Funtionality?)

I'm a bit wedged understanding how to make the timer component work like
the ol 'wait' function in clipper....

I've seen examples in the helps on how to spawn another window that has a
timer control in it.. then after a certain period the windows closes...

All I want to do on my (only) form is to make an image and a label
visible for, say 3 seconds...then make them invisible again.... dont want
to show another form.

Is there a way?  I'm still using the 16 bit delphi

thanks

rich pinder
rpin...@usc.edu

 

Re:Timer Ques ('Wait' Funtionality?)


I'm a bit wedged understanding how to make the timer component work like
the ol 'wait' function in clipper....

I've seen examples in the helps on how to spawn another window that has a
timer control in it.. then after a certain period the windows closes...

All I want to do on my (only) form is to make an image and a label
visible for, say 3 seconds...then make them invisible again.... dont want
to show another form.

Is there a way?  I'm still using the 16 bit delphi

thanks

rich pinder
rpin...@usc.edu

Re:Timer Ques ('Wait' Funtionality?)


Quote
Rich Pinder wrote:

> I'm a bit wedged understanding how to make the timer component work like
> the ol 'wait' function in clipper....

> I've seen examples in the helps on how to spawn another window that has a
> timer control in it.. then after a certain period the windows closes...

> All I want to do on my (only) form is to make an image and a label
> visible for, say 3 seconds...then make them invisible again.... dont want
> to show another form.

> Is there a way?  I'm still using the 16 bit delphi

> thanks

> rich pinder
> rpin...@usc.edu

There is a timer included in the Windows toolhelp.dll
and I have some code that uses that for pausing. You must add
Toolhelp to the 'Uses' clause of the form.'ms' is pause time in
milliseconds.

procedure TForm1.Pause (ms: LongInt);
var
TimeRec: TTimerInfo;
TimeStart : LongInt;

begin
         TimeRec.dwSize := SizeOf(TimeRec);
         TimerCount(@TimeRec);
         TimeStart := TimeRec.dwmsS{*word*168}art;
         repeat
         Application.ProcessMessages;
         TimerCount(@TimeRec);
         until TimeRec.dwmsS{*word*168}art > (TimeStart + ms);

end;

Re:Timer Ques ('Wait' Funtionality?)


Quote
Peter Antypas <panty...@hic.net> wrote:

>There is a timer included in the Windows toolhelp.dll
>and I have some code that uses that for pausing. You must add
>Toolhelp to the 'Uses' clause of the form.'ms' is pause time in
>milliseconds.

>procedure TForm1.Pause (ms: LongInt);
>var
>TimeRec: TTimerInfo;
>TimeStart : LongInt;

>begin
>     TimeRec.dwSize := SizeOf(TimeRec);
>     TimerCount(@TimeRec);
>     TimeStart := TimeRec.dwmsS{*word*168}art;
>     repeat
>     Application.ProcessMessages;
>     TimerCount(@TimeRec);
>     until TimeRec.dwmsS{*word*168}art > (TimeStart + ms);
>end;

This is useful information.  Where is this kind of information
documented? I'd like to get the details as well as any other useful
functions?  Thanks

Al

============================================================
 Al Testani ============= Boca Raton, FL ==============  a...@emi.net
============================================================

Re:Timer Ques ('Wait' Funtionality?)


Quote
Peter Antypas wrote:

.> There is a timer included in the Windows toolhelp.dll
.> and I have some code that uses that for pausing. You must add
.> Toolhelp to the 'Uses' clause of the form.'ms' is pause time in
.> milliseconds.
.>
.> procedure TForm1.Pause (ms: LongInt);
.> var
.> TimeRec: TTimerInfo;
.> TimeStart : LongInt;
.>
.> begin
.>          TimeRec.dwSize := SizeOf(TimeRec);
.>          TimerCount(@TimeRec);
.>          TimeStart := TimeRec.dwmsS{*word*168}art;
.>          repeat
.>          Application.ProcessMessages;
.>          TimerCount(@TimeRec);
.>          until TimeRec.dwmsS{*word*168}art > (TimeStart + ms);
.>
.> end;

But, if you put the Win95 system monitor (not part of the default installation)
on during execution, you will find that the repeat..app.pmess...until is a CPU
sucker.  There REALLY should be a less CPU intensive way of doing this...

Or am I misreading the evidence from the system monitor?
--

<POOF!>

---------------------Jeffrey David M. Schrab------------------------
PERSONAL:sch...@mail.atw.fullfeed.com      BUSINESS:jsch...@qdyn.com
Sam&Max - Max:"My head's caught fire, Sam.  Now what?"
--------------------------------------------------------------------

Re:Timer Ques ('Wait' Funtionality?)


Quote
Rich Pinder <rpin...@usc.edu> wrote:
>I'm a bit wedged understanding how to make the timer component work like
>the ol 'wait' function in clipper....
>I've seen examples in the helps on how to spawn another window that has a
>timer control in it.. then after a certain period the windows closes...
>All I want to do on my (only) form is to make an image and a label
>visible for, say 3 seconds...then make them invisible again.... dont want
>to show another form.
>Is there a way?  I'm still using the 16 bit delphi
>thanks
>rich pinder
>rpin...@usc.edu

Try this in the OnTimer Event for your TTimer component.

procedure TForm1.Timer1Timer(Sender: TObject);
var ShowLabel:Boolean;
begin
  Label1.Caption:='(Whatever you want in here');
  If ShowLabel then Label1.Visible:=True else Label.Visible:=False;;
  ShowLabel := Not(ShowLabel);
end;

This will make the label blink on and off every 3 seconds. (If you set
the Interval property to 3000). It shouldn't be hard to adapt it if
you only want it to blink once. Simply disable the TTimer component
after you hide the label.

Re:Timer Ques ('Wait' Funtionality?)


Quote
Rich Pinder wrote:

> I'm a bit wedged understanding how to make the timer component work like
> the ol 'wait' function in clipper....

> I've seen examples in the helps on how to spawn another window that has a
> timer control in it.. then after a certain period the windows closes...

> All I want to do on my (only) form is to make an image and a label
> visible for, say 3 seconds...then make them invisible again.... dont want
> to show another form.

> Is there a way?  I'm still using the 16 bit delphi

> thanks

> rich pinder
> rpin...@usc.edu

Well you can cheat and do it like we use to back in the old'n days:

  Splashform := TSplashForm.Create(application);
  Splashform.show;
  Splashform.update;
  for x := 1 to 10000 do
    x := x + 1;
  Splashform.hide;
  splashform.free;

Note: for x := 1 to any number (the larger the number, the longer the delay)

Jason Koch
p...@primenet.com

Re:Timer Ques ('Wait' Funtionality?)


Quote
Peter Antypas wrote:

> Rich Pinder wrote:

> > I'm a bit wedged understanding how to make the timer component work like
> > the ol 'wait' function in clipper....

> > I've seen examples in the helps on how to spawn another window that has a
> > timer control in it.. then after a certain period the windows closes...

> > All I want to do on my (only) form is to make an image and a label
> > visible for, say 3 seconds...then make them invisible again.... dont want
> > to show another form.

> > Is there a way?  I'm still using the 16 bit delphi

> > thanks

> > rich pinder
> > rpin...@usc.edu

   Create the image and label components, set their visible properties to
false.

   Add a timer component; set the interval property to the desired length;
set enabled to false.

   Add an OnTimer handler, in it change the enabled property of the timer,
and the visible properties of image and label to false.

   When you want to display them, make the label and image visible, and
enable the timer.  The timer will make them invisible and them stop after the
set time.

== Brian

Re:Timer Ques ('Wait' Funtionality?)


Quote
In article <318E169E...@usc.edu>, Rich Pinder <rpin...@usc.edu> wrote:
>I'm a bit wedged understanding how to make the timer component work like
>the ol 'wait' function in clipper....

>I've seen examples in the helps on how to spawn another window that has a
>timer control in it.. then after a certain period the windows closes...

>All I want to do on my (only) form is to make an image and a label
>visible for, say 3 seconds...then make them invisible again.... dont want
>to show another form.

>Is there a way?  I'm still using the 16 bit delphi

Just put a timer on your main form and hide the image and label in the Timer
event handler. Kill the timer there if you don't to do anything else with it.

Re:Timer Ques ('Wait' Funtionality?)


Precision Key Computing <p...@primenet.com> wrote:

Quote
>Rich Pinder wrote:

>> I'm a bit wedged understanding how to make the timer component work like
>> the ol 'wait' function in clipper....

>Well you can cheat and do it like we use to back in the old'n days:

...

Quote
>  for x := 1 to 10000 do
>    x := x + 1;

Not very friendly! That would be straight in the bin, if I wanted it
to coexist with other programs. Also, of course, the wait gets shorter
with the speed of the processor. And, Delphi 2 might optimize a
pointless loop out of existence! To do it properly you need to enter a
message loop, which also tests a flag; when the timer is received it
sets the flag.
----------------------------------------
Aandi Inston  qu...@dial.pipex.com
Visit http://ds.dial.pipex.com/quite for info on PostScript,
PSAlter, psalters, tea, and small {*word*141} animals. And stuff.  

Re:Timer Ques ('Wait' Funtionality?)


On Wed, 08 May 1996 12:27:24 GMT, 100126.1...@compuserve.com (Aandi Inston)
wrote:

Quote
>Precision Key Computing <p...@primenet.com> wrote:
>>  for x := 1 to 10000 do
>>    x := x + 1;

doesnt really match the "precision" in your company name eh?
not to mention that THIS loop will not compile under Delphi 2.0
or at least give a warning since you're changing the loop value within
the loop itself...

---
Laurens v. Alphen,  Beach Dreamin' Software, `BeAcH` on IRC
Calslaan 42, 2804 RT Gouda, THE NETHERLANDS, +31 182 539003
email: l...@wirehub.net, website: http://www.wirehub.nl/~lva

"When a lie is told a hundred times, it becomes the truth"

Re:Timer Ques ('Wait' Funtionality?)


Quote
Rich Pinder <rpin...@usc.edu> wrote:
>I'm a bit wedged understanding how to make the timer component work like
>the ol 'wait' function in clipper....
>I've seen examples in the helps on how to spawn another window that has a
>timer control in it.. then after a certain period the windows closes...
>All I want to do on my (only) form is to make an image and a label
>visible for, say 3 seconds...then make them invisible again.... dont want
>to show another form.

Here's procedure to make delay for ms milliseconds:

procedure Pause(ms: longint);
begin
  ms := ms + GetTickCount;
  repeat
    Application.ProcessMessages;
  until GetTickCount >= ms;
end;

GetTickCount is defined in the WinProcs unit. If you wan't totally
freeze your Windows for ms millisecond just delete line containing
application.ProcessMessages;

- Ari
__________________________________________________
Ari Hirviniemi, Lappeenranta, Finland (a...@iki.fi)
All my opinions and comments are personal and have
nothing to do with my employer.

Re:Timer Ques ('Wait' Funtionality?)


Quote
Rich Pinder wrote:

> All I want to do on my (only) form is to make an image and a label
> visible for, say 3 seconds...then make them invisible again.... dont want
> to show another form.

> Is there a way?  I'm still using the 16 bit delphi

> thanks

> rich pinder
> rpin...@usc.edu

The right thing to do is use the Windows API function GetTickCount.
Here's a simple Wait function:

procedure Wait(ms: Longint);  { Wait for a number of milliseconds }
var
  t: Longint;
begin
  t := GetTickCount;
  repeat until GetTickCount - t > ms;
end;

This is "busy-wait", of course, and does not let other
applications run, so use only for short times, say max 3 seconds.

Regards,

Matthias Bolliger

Re:Timer Ques ('Wait' Funtionality?)


Quote
Matthias Bolliger wrote:

> Rich Pinder wrote:

> > All I want to do on my (only) form is to make an image and a label<snip>
<snip>
> > rich pinder
> > rpin...@usc.edu

> The right thing to do is use the Windows API function GetTickCount.
> procedure Wait(ms: Longint);  { Wait for a number of milliseconds }
> var
>   t: Longint;
> begin
>   t := GetTickCount;
>   repeat until GetTickCount - t > ms;
> end;
> <snip>
<snip>
> This is "busy-wait", of course, and does not let other
> applications run, so use only for short times, say max 3 seconds.

> Regards,

> Matthias Bolliger--

Try this:

        procedure DelayMilliSec(MSecs : LongInt);
        Var
                LastTickCount   :       LongInt;
        begin
                LastTickCount   :=      GetTickCount + MSecs;
                repeat
                        Application.processmessages;
                until (GetTickCount >= LastTickCount);
        end;

Best wishes
Rune
--
Rune Olofsson     ,__@      Q
Micro Bit        _`\<,_    <\
Uppsala Sweden  (_)/ (_)  / >
Clipper->Delphi->Pinarello Treviso -85/Campa. Chorus

Other Threads