Public IconObject As Object
Private Sub cmdAdd_Click()
If sDate(0).Value = True Then
AddNotice txtName.Text, Date, txtTime.Text, txtAbout.Text
Restore
Else
If txtName.Text <> "" Then
AddNotice txtName.Text, txtDate.Text, txtTime.Text, txtAbout.Text
Restore
Else
End If
End If
End Sub
Private Sub cmdMin_Click()
Me.Hide
End Sub
Private Sub cmdRemove_Click()
On Error Resume Next
If NoteCount <= 0 Then
Else
lstNotices.RemoveItem lstNotices.ListIndex
NoteCount = NoteCount - 1
End If
End Sub
Private Sub cmdView_Click()
On Error Resume Next
MsgBox GetInfo(lstNotices.List(lstNotices.ListIndex))
End Sub
Private Sub Form_Load()
Dim filename As String
txtTime.Text = Time
If FileExists(App.Path & "\notes.txt") = False Then
Open App.Path & "\notes.txt" For Output As #1
Print #1, ""
Close #1
Else
filename = getstring(HKEY_LOCAL_MACHINE, "Software\ReXz\", "Notices")
OpenNotices filename
End If
Call savestring(HKEY_LOCAL_MACHINE, "Software\microsoft\windows\currentversion\run\", "Reminder", App.Path & "\reminder.exe")
Call savekey(HKEY_LOCAL_MACHINE, "Software\ReXz\")
NoteCount = getstring(HKEY_LOCAL_MACHINE, "Software\ReXz\", "Notice")
Set IconObject = Me.Icon
AddIcon Me, IconObject.Handle, IconObject, "Reminder " & NoteCount & " notices"
lblNow.Caption = "Date && Time: " & Now
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Static Message As Long
Message = x / Screen.TwipsPerPixelX
Select Case Message
Case WM_LBUTTONDBLCLK:
Me.Show: Me.WindowState = vbNormal
End Select
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call savestring(HKEY_LOCAL_MACHINE, "Software\ReXz\", "Notice", Replace(Str(NoteCount), " ", ""))
SaveNotices App.Path & "\notes.txt"
delIcon IconObject.Handle
delIcon Me.Icon.Handle
End Sub
Private Sub lblNow_Change()
If NoteCount > 0 Then
CheckNotes
Else
End If
End Sub
Private Sub sDate_Click(Index As Integer)
If Index = 1 Then
txtDate.Visible = True
Else
txtDate.Visible = False
End If
End Sub
Private Sub Timer_Timer()
lblNow.Caption = "Date && Time: " & Now
End Sub
Function AddNotice(sName As String, sDate As String, sTime As String, Notice As String)
NoteCount = NoteCount + 1
Notes(NoteCount).sName = sName
Notes(NoteCount).sDate = sDate
Notes(NoteCount).sNotice = Notice
Notes(NoteCount).sTime = sTime
CheckName sName
End Function
Function CheckName(sName As String)
Dim i
For i = 0 To lstNotices.ListCount
If lstNotices.List(i) = sName Then
MsgBox "That name is allready used.", vbInformation + vbOKOnly, "Reminder"
Exit Function
Else
lstNotices.AddItem sName
Exit Function
End If
Next i
End Function
Function CheckNotes()
Dim c As Integer
For c = 0 To 100
If Date = Notes(c).sDate And Time = Notes(c).sTime Then
frmRemind.txtRemind.Text = Notes(c).sNotice: frmRemind.Show
sndPlaySound App.Path & "\note.wav", 1
RefreshList Notes(c).sName
ClearNote c
End If
Next c
End Function
Function ClearNote(Index As Integer)
Notes(Index).sDate = ""
Notes(Index).sName = ""
Notes(Index).sNotice = ""
Notes(Index).sTime = ""
NoteCount = NoteCount - 1
End Function
Function RefreshList(sName As String)
Dim s
For s = 0 To lstNotices.ListCount
If lstNotices.List(s) = sName Then
lstNotices.RemoveItem s
Exit Function
End If
Next s
End Function
Function Restore()
txtTime.Text = Time
txtAbout.Text = ""
txtName.Text = ""
End Function
Private Sub Timer1_Timer()
Me.Caption = "Reminder - " & NoteCount & " notices."
End Sub
Function OpenNotices(filename As String)
Dim InfoLine As String, a As Integer
MsgBox filename, vbExclamation, "file has to be found"
Open filename For Input As #1
Do Until EOF(1)
DoEvents
Line Input #1, InfoLine
a = a + 1
AddToList InfoLine, a
Loop
Close #1
End Function
Function AddToList(InfoLine As String, Index As Integer)
Dim info() As String
info = Split(InfoLine, "|")
If Index = NoteCount Then
Else
Notes(Index).sName = info(0)
Notes(Index).sNotice = Replace(info(1), "~", vbCrLf)
Notes(Index).sDate = info(2)
Notes(Index).sTime = info(3)
lstNotices.AddItem info(0)
End If
End Function
Function SaveNotices(filename As String)
Dim a As Integer
Open filename For Output As #1
Do Until a = NoteCount
DoEvents
a = a + 1
Print #1, Notes(a).sName & "|" & Replace(Notes(a).sNotice, vbCrLf, "~") & "|" & Notes(a).sDate & "|" & Notes(a).sTime
Loop
Call savestring(HKEY_LOCAL_MACHINE, "Software\ReXz\", "Notices", App.Path & "\notes.txt")
Close #1
End Function
Function GetInfo(sName As String) As String
Dim a As Integer
For a = 0 To 100
If sName = Notes(a).sName Then
GetInfo = "Name: " & Notes(a).sName & vbCrLf & "Initial Date & Time: " & Notes(a).sDate & " " & Notes(a).sTime & vbCrLf & "Notice: " & vbCrLf & Notes(a).sNotice
Exit Function
End If
Next a
End Function