Option Explicit
Private Declare PtrSafe Function FindWindowA Lib "user32" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare PtrSafe Function SetWindowPos Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private Declare PtrSafe Function SetTimer Lib "user32" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerfunc As Long) As Long
Private Declare PtrSafe Function KillTimer Lib "user32" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long) As Long
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const FLAGS As Long = SWP_NOMOVE Or SWP_NOSIZE
Private Const HWND_TOPMOST = -1
Private TimerID As Long 'Need a timer ID to eventually turn off the timer. If the timer ID is not 0 then the timer is running
Public Sub ActivateTimer(ByVal nSeconds As Long)
'The SetTimer call accepts milliseconds, so convert to seconds
nSeconds = nSeconds * 1000
' Check to see if timer is running before call to SetTimer
If TimerID <> 0 Then Call DeactivateTimer
TimerID = SetTimer(0, 0, nSeconds, AddressOf Reminder_Helper)
If TimerID = 0 Then MsgBox "The timer failed to activate."
End Sub
Public Sub DeactivateTimer()
Dim lSuccess As Long
If TimerID <> 0 Then
lSuccess = KillTimer(0, TimerID)
If lSuccess = 0 Then
MsgBox "The timer failed to deactivate."
Else
TimerID = 0
End If
End If
End Sub
Private Sub Reminder_Helper(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idevent As Long, ByVal Systime As Long)
Dim ReminderWindowHWnd As Variant
If idevent = TimerID Then
On Error Resume Next
ReminderWindowHWnd = FindWindowA(vbNullString, "1 Reminder")
SetWindowPos ReminderWindowHWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS
DeactivateTimer
End If
End Sub
Man, I wish I could induce that behaviour from Outlook. :( – JMD – 2009-09-29T17:09:15.230
@JMD: Much as I hate windows stealing focus, I've been late for the past two Tuesday morning meetings. – David Thornley – 2009-09-29T17:16:21.503