ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   API Timer (https://www.excelbanter.com/excel-programming/287735-api-timer.html)

Seth[_5_]

API Timer
 
I am using the API timer functions to emulate the VB
timer capability in an Excel project (see following code):


--------------------------------------------------------
Public Declare Function SetTimer Lib "user32" (ByVal hwnd
As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As
Long
Public Declare Function KillTimer Lib "user32" (ByVal
hwnd As Long, ByVal nIDEvent As Long) As Long

Public TimerID As Long
Public TimerSeconds As Single

Sub StartTimer()
TimerSeconds = 1 ' how often to "pop" the timer.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&,
AddressOf TimerProc)
End Sub

Sub EndTimer()
On Error Resume Next
KillTimer 0&, TimerID
End Sub

Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
' My code here
End Sub
--------------------------------------------------------

OK, so everything works well until I call the EndTimer
function (I call this function when I terminate a
userform). I go back to the Excel interface but I can't
use the mouse to click on anything (cells, toolbars,
etc.).

Anybody know what is going on here?

Thanks,

Seth

Bob Phillips[_6_]

API Timer
 
Seth,

I don't get this problem. You do have XL2000 or later don't you?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Seth" wrote in message
...
I am using the API timer functions to emulate the VB
timer capability in an Excel project (see following code):


--------------------------------------------------------
Public Declare Function SetTimer Lib "user32" (ByVal hwnd
As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As
Long
Public Declare Function KillTimer Lib "user32" (ByVal
hwnd As Long, ByVal nIDEvent As Long) As Long

Public TimerID As Long
Public TimerSeconds As Single

Sub StartTimer()
TimerSeconds = 1 ' how often to "pop" the timer.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&,
AddressOf TimerProc)
End Sub

Sub EndTimer()
On Error Resume Next
KillTimer 0&, TimerID
End Sub

Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
' My code here
End Sub
--------------------------------------------------------

OK, so everything works well until I call the EndTimer
function (I call this function when I terminate a
userform). I go back to the Excel interface but I can't
use the mouse to click on anything (cells, toolbars,
etc.).

Anybody know what is going on here?

Thanks,

Seth




Seth[_5_]

API Timer
 
Yes, I have XL XP.

The problem is that once i turn off the timer, I cannot
get back into Excel (i.e., I can't click on anything, I
just get the standard mouse pointer - I can't select
cells, click buttons or anything). It is like Excel is
frozen almost, but I can still edit in the VBE.

It is odd, and I wasn't sure if anyone else had
experienced this.

Seth


-----Original Message-----
Seth,

I don't get this problem. You do have XL2000 or later

don't you?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Seth" wrote in message
...
I am using the API timer functions to emulate the VB
timer capability in an Excel project (see following

code):


-------------------------------------------------------

-
Public Declare Function SetTimer Lib "user32" (ByVal

hwnd
As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long)

As
Long
Public Declare Function KillTimer Lib "user32" (ByVal
hwnd As Long, ByVal nIDEvent As Long) As Long

Public TimerID As Long
Public TimerSeconds As Single

Sub StartTimer()
TimerSeconds = 1 ' how often to "pop" the timer.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&,
AddressOf TimerProc)
End Sub

Sub EndTimer()
On Error Resume Next
KillTimer 0&, TimerID
End Sub

Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
' My code here
End Sub
-------------------------------------------------------

-

OK, so everything works well until I call the EndTimer
function (I call this function when I terminate a
userform). I go back to the Excel interface but I

can't
use the mouse to click on anything (cells, toolbars,
etc.).

Anybody know what is going on here?

Thanks,

Seth



.



All times are GMT +1. The time now is 08:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com