home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Streaming_2113155182008.psc / Clock.frm < prev    next >
Text File  |  2008-05-15  |  14KB  |  414 lines

  1. VERSION 5.00
  2. Object = "{6BF52A50-394A-11D3-B153-00C04F79FAA6}#1.0#0"; "wmp.dll"
  3. Begin VB.Form Clock 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "Streaming Alarm Clock Radio 3.5"
  6.    ClientHeight    =   1395
  7.    ClientLeft      =   45
  8.    ClientTop       =   435
  9.    ClientWidth     =   9810
  10.    ControlBox      =   0   'False
  11.    Icon            =   "Clock.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    LockControls    =   -1  'True
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   1395
  17.    ScaleWidth      =   9810
  18.    StartUpPosition =   2  'CenterScreen
  19.    Begin VB.CommandButton Command7 
  20.       Caption         =   "M5"
  21.       Height          =   330
  22.       Left            =   8850
  23.       TabIndex        =   11
  24.       Top             =   1020
  25.       Width           =   390
  26.    End
  27.    Begin VB.CommandButton Command6 
  28.       Caption         =   "M4"
  29.       Height          =   330
  30.       Left            =   8430
  31.       TabIndex        =   10
  32.       Top             =   1020
  33.       Width           =   390
  34.    End
  35.    Begin VB.CommandButton Command5 
  36.       Caption         =   "M3"
  37.       Height          =   330
  38.       Left            =   8010
  39.       TabIndex        =   9
  40.       Top             =   1020
  41.       Width           =   390
  42.    End
  43.    Begin VB.CommandButton Command4 
  44.       Caption         =   "M2"
  45.       Height          =   330
  46.       Left            =   7590
  47.       TabIndex        =   8
  48.       Top             =   1020
  49.       Width           =   390
  50.    End
  51.    Begin VB.CommandButton Command3 
  52.       Caption         =   "M1"
  53.       Height          =   330
  54.       Left            =   7170
  55.       TabIndex        =   7
  56.       Top             =   1020
  57.       Width           =   390
  58.    End
  59.    Begin VB.Timer Timer2 
  60.       Enabled         =   0   'False
  61.       Interval        =   10
  62.       Left            =   780
  63.       Top             =   1995
  64.    End
  65.    Begin VB.CommandButton Command2 
  66.       Caption         =   "X"
  67.       BeginProperty Font 
  68.          Name            =   "Trebuchet MS"
  69.          Size            =   12
  70.          Charset         =   0
  71.          Weight          =   700
  72.          Underline       =   0   'False
  73.          Italic          =   -1  'True
  74.          Strikethrough   =   0   'False
  75.       EndProperty
  76.       Height          =   330
  77.       Left            =   9360
  78.       TabIndex        =   6
  79.       ToolTipText     =   "Minimize to tray."
  80.       Top             =   1020
  81.       Width           =   390
  82.    End
  83.    Begin VB.CommandButton Command1 
  84.       Caption         =   "Settings"
  85.       Height          =   330
  86.       Left            =   6090
  87.       TabIndex        =   5
  88.       ToolTipText     =   "Settings"
  89.       Top             =   1020
  90.       Width           =   885
  91.    End
  92.    Begin VB.CheckBox Check1 
  93.       Caption         =   "Alarm Set"
  94.       Height          =   255
  95.       Left            =   5025
  96.       TabIndex        =   4
  97.       Top             =   1058
  98.       Width           =   1020
  99.    End
  100.    Begin VB.Timer Timer1 
  101.       Interval        =   1000
  102.       Left            =   300
  103.       Top             =   2040
  104.    End
  105.    Begin VB.Label AlarmTimeDsp 
  106.       Alignment       =   2  'Center
  107.       BackColor       =   &H00000000&
  108.       BorderStyle     =   1  'Fixed Single
  109.       Caption         =   "00:00"
  110.       BeginProperty Font 
  111.          Name            =   "Tahoma"
  112.          Size            =   14.25
  113.          Charset         =   0
  114.          Weight          =   700
  115.          Underline       =   0   'False
  116.          Italic          =   0   'False
  117.          Strikethrough   =   0   'False
  118.       EndProperty
  119.       ForeColor       =   &H000000FF&
  120.       Height          =   435
  121.       Left            =   8145
  122.       TabIndex        =   3
  123.       ToolTipText     =   "Alarm Time"
  124.       Top             =   525
  125.       Width           =   1560
  126.    End
  127.    Begin WMPLibCtl.WindowsMediaPlayer WindowsMediaPlayer1 
  128.       Height          =   930
  129.       Left            =   5025
  130.       TabIndex        =   2
  131.       Top             =   60
  132.       Width           =   4740
  133.       URL             =   ""
  134.       rate            =   1
  135.       balance         =   0
  136.       currentPosition =   0
  137.       defaultFrame    =   ""
  138.       playCount       =   1
  139.       autoStart       =   -1  'True
  140.       currentMarker   =   0
  141.       invokeURLs      =   -1  'True
  142.       baseURL         =   ""
  143.       volume          =   50
  144.       mute            =   0   'False
  145.       uiMode          =   "full"
  146.       stretchToFit    =   0   'False
  147.       windowlessVideo =   0   'False
  148.       enabled         =   -1  'True
  149.       enableContextMenu=   -1  'True
  150.       fullScreen      =   0   'False
  151.       SAMIStyle       =   ""
  152.       SAMILang        =   ""
  153.       SAMIFilename    =   ""
  154.       captioningID    =   ""
  155.       enableErrorDialogs=   0   'False
  156.       _cx             =   8361
  157.       _cy             =   1640
  158.    End
  159.    Begin VB.Label Label2 
  160.       Alignment       =   2  'Center
  161.       BackColor       =   &H00000000&
  162.       Caption         =   "TAS Independent Programming"
  163.       BeginProperty Font 
  164.          Name            =   "Tahoma"
  165.          Size            =   11.25
  166.          Charset         =   0
  167.          Weight          =   700
  168.          Underline       =   0   'False
  169.          Italic          =   0   'False
  170.          Strikethrough   =   0   'False
  171.       EndProperty
  172.       ForeColor       =   &H0000FF00&
  173.       Height          =   345
  174.       Left            =   60
  175.       TabIndex        =   1
  176.       Top             =   1020
  177.       Width           =   4905
  178.    End
  179.    Begin VB.Label Label1 
  180.       Alignment       =   2  'Center
  181.       BackColor       =   &H00000000&
  182.       Caption         =   "00:00:00"
  183.       BeginProperty Font 
  184.          Name            =   "Tahoma"
  185.          Size            =   36
  186.          Charset         =   0
  187.          Weight          =   700
  188.          Underline       =   0   'False
  189.          Italic          =   0   'False
  190.          Strikethrough   =   0   'False
  191.       EndProperty
  192.       ForeColor       =   &H000000FF&
  193.       Height          =   930
  194.       Left            =   60
  195.       TabIndex        =   0
  196.       ToolTipText     =   "Time. You can change between 12 or 24 hour display in settings."
  197.       Top             =   60
  198.       Width           =   4905
  199.    End
  200.    Begin VB.Menu mnuSysTray 
  201.       Caption         =   "mnuSysTray"
  202.       Visible         =   0   'False
  203.       Begin VB.Menu MnuShow 
  204.          Caption         =   "Show"
  205.       End
  206.       Begin VB.Menu MnuVisualize 
  207.          Caption         =   "Visualize"
  208.       End
  209.       Begin VB.Menu MnuExit 
  210.          Caption         =   "Exit"
  211.       End
  212.    End
  213. End
  214. Attribute VB_Name = "Clock"
  215. Attribute VB_GlobalNameSpace = False
  216. Attribute VB_Creatable = False
  217. Attribute VB_PredeclaredId = True
  218. Attribute VB_Exposed = False
  219. Option Explicit
  220. Public Military As Boolean
  221. Public AlarmTime As Date
  222. Public AlarmStream As String
  223. Public AlarmFile As String
  224. Public OgVol As Integer
  225. Private MyCap As String
  226. Private OldMem As String
  227. Private Sub Command2_Click()
  228.     Me.Hide
  229.     Unload Settings
  230. End Sub
  231. Private Sub Command3_Click()
  232.     On Error Resume Next
  233.     WindowsMediaPlayer1.SetFocus
  234. Preselect 1, True
  235. End Sub
  236. Public Function Preselect(Memory As Integer, Optional Playing As Boolean)
  237. Dim MemStr As String
  238. 'Dim Playing As Boolean
  239. If WindowsMediaPlayer1.playState = wmppsPlaying Then Playing = True
  240. SaveSetting "Streaming Radio Alarm Clock", "Settings", "M" & OldMem & "V", WindowsMediaPlayer1.Settings.volume
  241. Me.Caption = MyCap & " - M" & Memory
  242. Select Case Memory
  243.          Case 1
  244.             MemStr = GetSetting("Streaming Radio Alarm Clock", "Settings", "M1", vbNullString)
  245.          Case 2:
  246.             MemStr = GetSetting("Streaming Radio Alarm Clock", "Settings", "M2", vbNullString)
  247.          Case 3:
  248.             MemStr = GetSetting("Streaming Radio Alarm Clock", "Settings", "M3", vbNullString)
  249.          Case 4:
  250.             MemStr = GetSetting("Streaming Radio Alarm Clock", "Settings", "M4", vbNullString)
  251.          Case 5:
  252.             MemStr = GetSetting("Streaming Radio Alarm Clock", "Settings", "M5", vbNullString)
  253. End Select
  254. SaveSetting "Streaming Radio Alarm Clock", "Settings", "Memory", Memory
  255. WindowsMediaPlayer1.Settings.volume = GetSetting("Streaming Radio Alarm Clock", "Settings", "M" & Memory & "V", "100")
  256. If MemStr <> vbNullString Then
  257. AlarmStream = MemStr
  258. WindowsMediaPlayer1.URL = AlarmStream
  259. If Playing = True Then WindowsMediaPlayer1.Controls.play
  260. End If
  261. OldMem = Memory
  262. End Function
  263. Private Sub Command4_Click()
  264. On Error Resume Next
  265.     WindowsMediaPlayer1.SetFocus
  266. Preselect 2, True
  267. End Sub
  268. Private Sub Command5_Click()
  269. On Error Resume Next
  270.     WindowsMediaPlayer1.SetFocus
  271. Preselect 3, True
  272. End Sub
  273. Private Sub Command6_Click()
  274. On Error Resume Next
  275.     WindowsMediaPlayer1.SetFocus
  276. Preselect 4, True
  277. End Sub
  278. Private Sub Command7_Click()
  279. On Error Resume Next
  280.     WindowsMediaPlayer1.SetFocus
  281. Preselect 5, True
  282. End Sub
  283. Private Sub MnuVisualize_Click()
  284.     If WindowsMediaPlayer1.playState = wmppsPlaying Then
  285.         WindowsMediaPlayer1.fullScreen = True
  286.     Else
  287.         MsgBox "Media must be playing before you can use this feature !"
  288.     End If
  289. End Sub
  290. Private Sub AlarmTimeDsp_Click()
  291.     Command1_Click
  292. End Sub
  293. Private Sub Check1_Click()
  294.     On Error Resume Next
  295.     WindowsMediaPlayer1.SetFocus
  296.     If Check1.Value = 1 And AlarmFile = vbNullString Then MsgBox "Please set the backup alarm file.": Settings.Show: Timer2.Enabled = True: Check1.Value = 0
  297.     If Check1.Value = 1 And AlarmStream = vbNullString Then MsgBox "Please set at least one stream.": Settings.Show: Timer2.Enabled = True: Check1.Value = 0
  298.     SaveSetting "Streaming Radio Alarm Clock", "Settings", "AlarmSet", Check1.Value
  299. End Sub
  300. Private Sub Command1_Click()
  301.     On Error Resume Next
  302.     WindowsMediaPlayer1.SetFocus
  303.     Settings.Show
  304.     Timer2.Enabled = True
  305.     If (Me.Top + Me.Height) + Settings.Height > Screen.Height Then Me.Top = Screen.Height - ((Me.Height + Settings.Height) + 1000)
  306. End Sub
  307. Private Sub Form_Load()
  308.     If App.PrevInstance Then
  309.         Unload Settings
  310.         Unload Me
  311.     End If
  312.     Me.Hide
  313.     MyCap = Me.Caption
  314.     AlarmFile = GetSetting("Streaming Radio Alarm Clock", "Settings", "AlarmFile", vbNullString)
  315.     WindowsMediaPlayer1.Settings.autoStart = False 'This here is a very important ingrediant
  316.     WindowsMediaPlayer1.Settings.volume = 100
  317.     Preselect GetSetting("Streaming Radio Alarm Clock", "Settings", "Memory", "1")
  318.     AlarmTime = CDate(GetSetting("Streaming Radio Alarm Clock", "Settings", "AlarmTime", "6:30:00 AM"))
  319.     Check1.Value = GetSetting("Streaming Radio Alarm Clock", "Settings", "AlarmSet", Check1.Value)
  320.     AddToTray Me, "Streaming Radio Alarm Clock", Me.Icon
  321.     btnFlat Command1
  322.     btnFlat Command2
  323.     btnFlat Command3
  324.     btnFlat Command4
  325.     btnFlat Command5
  326.     btnFlat Command6
  327.     btnFlat Command7
  328.     OgVol = GetMasterVolume_Value
  329.     AlarmTimeDsp.Caption = Format(AlarmTime, "h:mm AMPM")
  330.     Clock
  331.     If AlarmFile = vbNullString Then MsgBox "Please set the backup alarm file.": Me.Show: Command1_Click: Exit Sub
  332.     If AlarmStream = vbNullString Then MsgBox "Please set at least one stream.": Me.Show: Command1_Click
  333. End Sub
  334. Private Sub Form_Unload(Cancel As Integer)
  335.     RemoveFromTray
  336.     Unload Settings
  337.     Unload Me
  338. End Sub
  339. Private Sub MnuExit_Click()
  340.     Unload Me
  341. End Sub
  342. Private Sub MnuShow_Click()
  343.     Me.Show
  344. End Sub
  345. Private Sub Timer1_Timer()
  346.     If Hour(Now) = Hour(AlarmTime) And Minute(Now) = Minute(DateAdd("n", -1, AlarmTime)) And Second(Now) = "0" And Check1.Value = 1 And WindowsMediaPlayer1.playState = wmppsPlaying Then WindowsMediaPlayer1.Controls.stop 'Makes sure mediaplayer is ready to alarm. Just in case someone goes to sleep with the radio going.
  347.     If Hour(Now) = Hour(AlarmTime) And Minute(Now) = Minute(AlarmTime) And Second(Now) = "0" And Check1.Value = 1 Then
  348.         Me.Show
  349.         PlayItLoud
  350.     End If
  351.     Clock
  352. End Sub
  353. Private Sub Clock()
  354.     If Military = True Then
  355.         Label1.Caption = Format(Now, "h:mm:ss")
  356.     Else
  357.         Label1.Caption = Format(Now, "h:mm:ss AMPM")
  358.     End If
  359.     Label2.Caption = Format(Now, "dddd, mmm d yyyy")
  360. End Sub
  361. Private Sub Timer2_Timer() 'Settings docking timer
  362.     Settings.Top = Me.Top + Me.Height
  363.     Settings.Left = (Me.Left + Me.Width) - Settings.Width
  364. End Sub
  365. Private Sub WindowsMediaPlayer1_MediaError(ByVal pMediaObject As Object)
  366.     WindowsMediaPlayer1.URL = AlarmFile
  367.     WindowsMediaPlayer1.Controls.play
  368.     MsgBox "Couldn't connect to internet !"
  369. End Sub
  370. Private Sub WindowsMediaPlayer1_PlayStateChange(ByVal NewState As Long)
  371.     Select Case NewState
  372.     Case wmppsMediaEnded
  373.         WindowsMediaPlayer1.Controls.stop
  374.     Case wmppsReady
  375.         WindowsMediaPlayer1.Controls.stop
  376.     Case wmppsStopped
  377.         SetMasterVolume_Value OgVol
  378.         WindowsMediaPlayer1.URL = AlarmStream
  379.     End Select
  380. End Sub
  381. Public Sub PlayItLoud()
  382.     Dim eType As eConnectionType
  383.     Dim sName As String
  384.     If WindowsMediaPlayer1.playState = wmppsStopped Or WindowsMediaPlayer1.playState = wmppsUndefined Or WindowsMediaPlayer1.playState = wmppsReady Then
  385.         If GetSetting("Streaming Radio Alarm Clock", "Settings", "RadioStream", "1") = 0 Or InternetConnected(sName, eType) = False Or AlarmStream = vbNullString Then
  386.             If AlarmFile = vbNullString Then MsgBox "Please choose a alarm sound file !": Exit Sub
  387.             OgVol = GetMasterVolume_Value
  388.             MasterVolume_Mute True, False
  389.             SetMasterVolume_Value "90"
  390.             WindowsMediaPlayer1.URL = AlarmFile
  391.         Else
  392.             OgVol = GetMasterVolume_Value
  393.             MasterVolume_Mute True, False
  394.             SetMasterVolume_Value "90"
  395.             WindowsMediaPlayer1.URL = AlarmStream
  396.         End If
  397.         WindowsMediaPlayer1.Controls.play
  398.     Else
  399.         WindowsMediaPlayer1.Controls.stop
  400.         SetMasterVolume_Value OgVol
  401.     End If
  402. End Sub
  403. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  404.     Dim Message As Long
  405.     Message = X / Screen.TwipsPerPixelX
  406.     Select Case Message
  407.     Case WM_RBUTTONUP
  408.         SetForegroundWindow Me.hwnd
  409.         PopupMenu mnuSysTray
  410.     Case WM_LBUTTONUP
  411.         Me.Show
  412.     End Select
  413. End Sub
  414.