G
Guest
Hi All,
I have a simple application that allows users to clock in and out and stores
the data for use by the payroll department. It spends most of its life as a
tray icon and when the user clicks on it, a clock-in/out form is displayed.
My problem is this:
I've added a timer to the main module to allow the user to set a time to be
reminded that they should clock back in/out. The timer works great (i.e. if
it's set to remind you at 5pm, it reminds you at 5pm), but when the elapsed
event fires and the clock-in/out form is displayed, the form elements don't
repaint themselves (it's just a frame with no components) and if you click
anywhere in the form, you get the windows error message that "the application
has stopped responding."
Here's the weird thing: The sub that I use to display the form after the
timer elapses is the same sub that I call when the user right-clicks the tray
icon and selects "Display Timeclock Form" and it works like a charm. I can
open and close the form all day long with the tray icon context menu, but
when I use the timer to display the form, it freezes.
Here's what I've got... simplified. Any insights would be greatly
appreciated!
Thanks!
Mike E.
Sub main()
reminderTimer = New Timer
reminderTimer.AutoReset = False
frmMain = New frmTimeTracker
'setup context menu
cMenu.MenuItems.Add("Open Time Tracker", AddressOf cMenu_Click)
cMenu.MenuItems.Add("Set / Reset Reminder Time", AddressOf
cMenu_Click)
cMenu.MenuItems.Add("Exit Time Tracker", AddressOf cMenu_Click)
'create tray icon
trayIcon.Text = Time Tracker"
trayIcon.Icon = frmMain.Icon
trayIcon.Visible = True
trayIcon.ContextMenu = cMenu
AddHandler reminderTimer.Elapsed, AddressOf OnTimerElapsed
Application.Run()
End Sub
Public Sub OnTimerElapsed(ByVal source As Object, ByVal e As
ElapsedEventArgs)
bReminderSet = False
reminderTimer.Enabled = False
reminderTimer.Close()
ShowTimecardForm()
End Sub
Private Sub ShowTimecardForm()
If (frmMain Is Nothing OrElse frmMain.IsDisposed) Then
frmMain = New frmTimeTracker
End If
frmMain.Show()
frmMain.txtPassword.Focus()
Application.DoEvents()
End Sub
I have a simple application that allows users to clock in and out and stores
the data for use by the payroll department. It spends most of its life as a
tray icon and when the user clicks on it, a clock-in/out form is displayed.
My problem is this:
I've added a timer to the main module to allow the user to set a time to be
reminded that they should clock back in/out. The timer works great (i.e. if
it's set to remind you at 5pm, it reminds you at 5pm), but when the elapsed
event fires and the clock-in/out form is displayed, the form elements don't
repaint themselves (it's just a frame with no components) and if you click
anywhere in the form, you get the windows error message that "the application
has stopped responding."
Here's the weird thing: The sub that I use to display the form after the
timer elapses is the same sub that I call when the user right-clicks the tray
icon and selects "Display Timeclock Form" and it works like a charm. I can
open and close the form all day long with the tray icon context menu, but
when I use the timer to display the form, it freezes.
Here's what I've got... simplified. Any insights would be greatly
appreciated!
Thanks!
Mike E.
Sub main()
reminderTimer = New Timer
reminderTimer.AutoReset = False
frmMain = New frmTimeTracker
'setup context menu
cMenu.MenuItems.Add("Open Time Tracker", AddressOf cMenu_Click)
cMenu.MenuItems.Add("Set / Reset Reminder Time", AddressOf
cMenu_Click)
cMenu.MenuItems.Add("Exit Time Tracker", AddressOf cMenu_Click)
'create tray icon
trayIcon.Text = Time Tracker"
trayIcon.Icon = frmMain.Icon
trayIcon.Visible = True
trayIcon.ContextMenu = cMenu
AddHandler reminderTimer.Elapsed, AddressOf OnTimerElapsed
Application.Run()
End Sub
Public Sub OnTimerElapsed(ByVal source As Object, ByVal e As
ElapsedEventArgs)
bReminderSet = False
reminderTimer.Enabled = False
reminderTimer.Close()
ShowTimecardForm()
End Sub
Private Sub ShowTimecardForm()
If (frmMain Is Nothing OrElse frmMain.IsDisposed) Then
frmMain = New frmTimeTracker
End If
frmMain.Show()
frmMain.txtPassword.Focus()
Application.DoEvents()
End Sub