home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "Module1"
- Option Explicit
-
- Public fMainForm As frmMain
- ' this is used to determine which button or menu item the user picked
- Public index As String
- Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
-
-
- Sub Main()
- Set fMainForm = New frmMain
- fMainForm.Show
-
- End Sub
-
- Public Sub ActivateAlarm(index As String)
- Select Case index
- Case Is = "Program"
- ' when the user chooses the file name from the
- ' dialog box the filename is placed in this label
- ' on the main form
- Call RunProgram(fMainForm.lblMsg.Caption)
- Case Is = "Sound"
- Call PlaySound(fMainForm.lblMsg.Caption)
-
- Case Is = "Message"
- Call ShowMessage(fMainForm.lblMsg.Caption)
-
- End Select
-
- End Sub
- Public Sub PlaySound(soundfile As String)
- Dim S As Long
- Const SYNC = 1
- ' disable the timer
- fMainForm.Timer1.Enabled = False
- S = sndPlaySound(ByVal soundfile, SYNC)
-
- End Sub
-
- Public Sub RunProgram(name As String)
- Dim x As Double
- fMainForm.Timer1.Enabled = False
- x = Shell(name, vbNormalFocus)
-
- End Sub
-
- Public Sub ShowMessage(msg As String)
- frmMain.Timer1.Enabled = False
- ' fmainform is defined in the module
- fMainForm.WindowState = 1
- Load frmMessage
- Call SetUpForm(frmMessage)
- frmMessage.Show
-
- End Sub
-
- Public Sub SetUpForm(frm As Form)
- Dim msg As String
- Dim WidthFactor As Integer
- Dim HeightFactor As Integer
- Dim LeftCoord As Integer
- Dim TopCoord As Integer
-
- ' get the users message
- msg = fMainForm.txtMessage.Text
-
- ' set up the form with all the correct options
- With frm
- .BackColor = fMainForm.txtMessage.BackColor
- .ForeColor = fMainForm.txtMessage.ForeColor
- .Font = fMainForm.txtMessage.Font
- .Font.Size = fMainForm.txtMessage.Font.Size
- .Font.Italic = fMainForm.txtMessage.Font.Italic
- .Font.Strikethrough = fMainForm.txtMessage.Font.Strikethrough
- .Font.Underline = fMainForm.txtMessage.Font.Underline
- .Font.Bold = fMainForm.txtMessage.Font.Bold
- .Width = .TextWidth(msg) + 500
- ' add twice the height so the form is not too small
- .Height = .TextHeight(msg) + .TextHeight(msg)
- End With
-
- ' here i am centering the users message on the form
- frm.Cls
- LeftCoord = frm.ScaleWidth / 2
- TopCoord = frm.ScaleHeight / 2
- LeftCoord = frm.ScaleLeft + LeftCoord
- TopCoord = frm.ScaleTop + TopCoord
- WidthFactor = frm.TextWidth(msg) / 2
- HeightFactor = frm.TextHeight(msg) / 2
- frm.CurrentX = LeftCoord - WidthFactor
- frm.CurrentY = TopCoord - HeightFactor
- frm.Print msg
- End Sub
-
-