set obj = new Timer ?? 
Author Message
 set obj = new Timer ??

is it a way to programatically create a Timer object except by embedding it
on a form?

 if not,  are there any controls that behave like a Timer object but can be
created with
the "new" syntax?

 help appreciated.



Tue, 01 Jan 2002 03:00:00 GMT  
 set obj = new Timer ??

http://www.mvps.org/ccrp/ High Performance Timer objects.

~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please post/reply to the newsgroup(s) so
that everyone can benefit from the discussion.

Regards,

Klaus H. Probst, MCP

       ICQ: 22454937
      The VB Box: http://members.xoom.com/kprobst/
~~~~~~~~~~~~~~~~~~~~~~~~~~~


Quote:
> is it a way to programatically create a Timer object except by embedding it
> on a form?

>  if not,  are there any controls that behave like a Timer object but can be
> created with
> the "new" syntax?

>  help appreciated.



Tue, 01 Jan 2002 03:00:00 GMT  
 set obj = new Timer ??
- Yes
Search in VB samples, XTimer.
________________________________________________
Harvey Triana
Visual Basic Developer MVP
http://www.eidos.es/VeXPERT


________________________________________________


is it a way to programatically create a Timer object except by embedding it
on a form?

 if not,  are there any controls that behave like a Timer object but can be
created with
the "new" syntax?

 help appreciated.



Thu, 03 Jan 2002 03:00:00 GMT  
 set obj = new Timer ??
        Hi. Somebody in this NG gave me the adress which I can't
remember right now, but here's what I found there:

Using a Timer Without a Form {28-May-1999}

The Timer control in VB must be situated on a form in order to be part
of
the project. In some cases, notably ActiveX servers, there may not be
any form to act as a host. Although in many cases a form can be loaded
and simply not shown, it is also possible to use a system timer via
API
calls without using a control.

Start a new project and place the following code in a module:
Option Explicit
Private Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, _
  ByVal nIDEvent As Long) As Long
Private Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, _
  ByVal nIDEvent As Long, ByVal uElapse As Long, _
  ByVal lpTimerFunc As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long

Public Function TimerEnable(ByVal hWnd As Long, _
  ByVal TimerID As Long, ByVal mSecs As Long) As Long
TimerEnable = SetTimer(hWnd, TimerID, mSecs, _
  AddressOf TimerFired)
End Function

Public Function TimerDisable(ByVal hWnd As Long, _
  ByVal TimerID As Long) As Long
TimerDisable = KillTimer(hWnd, TimerID)
End Function

Private Sub TimerFired(ByVal hWnd As Long, _
  ByVal TimerID As Long, ByVal IDEvent As Long, _
  ByVal dwTime As Long)
Debug.Print "Fired "; hWnd; TimerID; IDEvent; dwTime
End Sub

Then place this code in a form (just for testing) after creating two
command buttons named cmdStart and cmdStop:
Option Explicit
Private mlTimer1 As Long
Private mlTimer2 As Long

Private Sub cmdStart_Click()
mlTimer1 = TimerEnable(0, 1, 3000)
mlTimer2 = TimerEnable(0, 2, 5000)
Debug.Print "Start 1: "; mlTimer1
Debug.Print "Start 2: "; mlTimer2
End Sub

Private Sub cmdStop_Click()
Debug.Print "Stop: "; TimerDisable(0, mlTimer1)
Debug.Print "Stop: "; TimerDisable(0, mlTimer2)
End Sub

When you run the application you should be able to click the START
button
and watch the timer events occurring in the debug window. Clicking
STOP
will terminate the timers. There are a few things to watch out for:
1. ALWAYS be sure to stop the timers before stopping the program. If
you
don't then the timers will continue to run and your app may appear in
the
tasklist after terminating.
2. The return value from the SetTimer call will be the IDEvent value
in
the function run when it fires. You can test this value to determine
which timer fired if more than one is started.
3. The function MUST be in a BAS module in VB5 due to restrictions in
the
AddressOf operator. If you need to reference it in multiple class or
other
modules then your function must know how to re-direct the event to the
appropriate place. An alternative is using a different function for
each
SetTimer call.

On Sun, 18 Jul 1999 19:55:41 -0500, "Harvey Triana"

Quote:

>- Yes
>Search in VB samples, XTimer.
>________________________________________________
>Harvey Triana
>Visual Basic Developer MVP
> http://www.*-*-*.com/


>________________________________________________



>is it a way to programatically create a Timer object except by embedding it
>on a form?

> if not,  are there any controls that behave like a Timer object but can be
>created with
>the "new" syntax?

> help appreciated.

Best regards,
       Zeljko

We are born {*filter*}, wet, and hungry.
Then things got worse.



Sat, 05 Jan 2002 03:00:00 GMT  
 set obj = new Timer ??

Quote:
> Hi. Somebody in this NG gave me the adress which I can't
> remember right now, but here's what I found there:

<cut>

The address is http://home.earthlink.net/~butlerbob/vb/misc/timer.htm



Sat, 05 Jan 2002 03:00:00 GMT  
 set obj = new Timer ??
        Thanks :)))



Quote:


>> Hi. Somebody in this NG gave me the adress which I can't
>> remember right now, but here's what I found there:
><cut>

>The address is http://www.*-*-*.com/ ~butlerbob/vb/misc/timer.htm

Best regards,
       Zeljko

We are born {*filter*}, wet, and hungry.
Then things got worse.



Mon, 07 Jan 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Dim obj As New Class crt Dim Obj As Class = New Class

2. Obj Ref not set to an instance of an Obj

3. timer obj instantiation

4. Process to replace old COM obj with new

5. Basic question...how to check obj set to Nothing

6. Set obj = nothing

7. Help with set obj and dereferencing?

8. Setting Obj = Nothing does not free memory

9. CR Engine Obj Lib vs CR Designer Component Obj Model

10. COM+ obj calling another COM+ obj

11. Dim as New vs. Set = New

12. New in declaration versus new in set statement

 

 
Powered by phpBB® Forum Software