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_2113415212008.psc / Clock.frm < prev    next >
Text File  |  2008-05-21  |  13KB  |  416 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.     Select Case Memory
  242.     Case 1
  243.         MemStr = GetSetting("Streaming Radio Alarm Clock", "Settings", "M1", vbNullString)
  244.     Case 2:
  245.         MemStr = GetSetting("Streaming Radio Alarm Clock", "Settings", "M2", vbNullString)
  246.     Case 3:
  247.         MemStr = GetSetting("Streaming Radio Alarm Clock", "Settings", "M3", vbNullString)
  248.     Case 4:
  249.         MemStr = GetSetting("Streaming Radio Alarm Clock", "Settings", "M4", vbNullString)
  250.     Case 5:
  251.         MemStr = GetSetting("Streaming Radio Alarm Clock", "Settings", "M5", vbNullString)
  252.     End Select
  253.     If MemStr <> vbNullString Then
  254.         SaveSetting "Streaming Radio Alarm Clock", "Settings", "Memory", Memory
  255.         WindowsMediaPlayer1.Settings.volume = GetSetting("Streaming Radio Alarm Clock", "Settings", "M" & Memory & "V", "100")
  256.         AlarmStream = MemStr
  257.         WindowsMediaPlayer1.URL = AlarmStream
  258.         Me.Caption = MyCap & " - M" & Memory
  259.         If Playing = True Then WindowsMediaPlayer1.Controls.play
  260.         OldMem = Memory
  261.     Else
  262.         MsgBox "You need to set this streams link."
  263.     End If
  264. End Function
  265. Private Sub Command4_Click()
  266.     On Error Resume Next
  267.     WindowsMediaPlayer1.SetFocus
  268.     Preselect 2, True
  269. End Sub
  270. Private Sub Command5_Click()
  271.     On Error Resume Next
  272.     WindowsMediaPlayer1.SetFocus
  273.     Preselect 3, True
  274. End Sub
  275. Private Sub Command6_Click()
  276.     On Error Resume Next
  277.     WindowsMediaPlayer1.SetFocus
  278.     Preselect 4, True
  279. End Sub
  280. Private Sub Command7_Click()
  281.     On Error Resume Next
  282.     WindowsMediaPlayer1.SetFocus
  283.     Preselect 5, True
  284. End Sub
  285. Private Sub MnuVisualize_Click()
  286.     If WindowsMediaPlayer1.playState = wmppsPlaying Then
  287.         WindowsMediaPlayer1.fullScreen = True
  288.     Else
  289.         MsgBox "Media must be playing before you can use this feature !"
  290.     End If
  291. End Sub
  292. Private Sub AlarmTimeDsp_Click()
  293.     Command1_Click
  294. End Sub
  295. Private Sub Check1_Click()
  296.     On Error Resume Next
  297.     WindowsMediaPlayer1.SetFocus
  298.     If Check1.Value = 1 And AlarmFile = vbNullString Then MsgBox "Please set the backup alarm file.": Settings.Show: Timer2.Enabled = True: Check1.Value = 0
  299.     If Check1.Value = 1 And AlarmStream = vbNullString Then MsgBox "Please set at least one stream.": Settings.Show: Timer2.Enabled = True: Check1.Value = 0
  300.     SaveSetting "Streaming Radio Alarm Clock", "Settings", "AlarmSet", Check1.Value
  301. End Sub
  302. Private Sub Command1_Click()
  303.     On Error Resume Next
  304.     WindowsMediaPlayer1.SetFocus
  305.     Settings.Show
  306.     Timer2.Enabled = True
  307.     If (Me.Top + Me.Height) + Settings.Height > Screen.Height Then Me.Top = Screen.Height - ((Me.Height + Settings.Height) + 1000)
  308. End Sub
  309. Private Sub Form_Load()
  310.     If App.PrevInstance Then
  311.         Unload Settings
  312.         Unload Me
  313.     End If
  314.     Me.Hide
  315.     MyCap = Me.Caption
  316.     AlarmFile = GetSetting("Streaming Radio Alarm Clock", "Settings", "AlarmFile", vbNullString)
  317.     WindowsMediaPlayer1.Settings.autoStart = False 'This here is a very important ingrediant
  318.     WindowsMediaPlayer1.Settings.volume = 100
  319.     Preselect GetSetting("Streaming Radio Alarm Clock", "Settings", "Memory", "1")
  320.     AlarmTime = CDate(GetSetting("Streaming Radio Alarm Clock", "Settings", "AlarmTime", "6:30:00 AM"))
  321.     Check1.Value = GetSetting("Streaming Radio Alarm Clock", "Settings", "AlarmSet", Check1.Value)
  322.     AddToTray Me, "Streaming Radio Alarm Clock", Me.Icon
  323.     btnFlat Command1
  324.     btnFlat Command2
  325.     btnFlat Command3
  326.     btnFlat Command4
  327.     btnFlat Command5
  328.     btnFlat Command6
  329.     btnFlat Command7
  330.     OgVol = GetMasterVolume_Value
  331.     AlarmTimeDsp.Caption = Format(AlarmTime, "h:mm AMPM")
  332.     Clock
  333.     If AlarmFile = vbNullString Then MsgBox "Please set the backup alarm file.": Me.Show: Command1_Click: Exit Sub
  334.     If AlarmStream = vbNullString Then MsgBox "Please set at least one stream.": Me.Show: Command1_Click
  335. End Sub
  336. Private Sub Form_Unload(Cancel As Integer)
  337.     RemoveFromTray
  338.     Unload Settings
  339.     Unload Me
  340. End Sub
  341. Private Sub MnuExit_Click()
  342.     Unload Me
  343. End Sub
  344. Private Sub MnuShow_Click()
  345.     Me.Show
  346. End Sub
  347. Private Sub Timer1_Timer()
  348.     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.
  349.     If Hour(Now) = Hour(AlarmTime) And Minute(Now) = Minute(AlarmTime) And Second(Now) = "0" And Check1.Value = 1 Then
  350.         Me.Show
  351.         PlayItLoud
  352.     End If
  353.     Clock
  354. End Sub
  355. Private Sub Clock()
  356.     If Military = True Then
  357.         Label1.Caption = Format(Now, "h:mm:ss")
  358.     Else
  359.         Label1.Caption = Format(Now, "h:mm:ss AMPM")
  360.     End If
  361.     Label2.Caption = Format(Now, "dddd, mmm d yyyy")
  362. End Sub
  363. Private Sub Timer2_Timer() 'Settings docking timer
  364.     Settings.Top = Me.Top + Me.Height
  365.     Settings.Left = (Me.Left + Me.Width) - Settings.Width
  366. End Sub
  367. Private Sub WindowsMediaPlayer1_MediaError(ByVal pMediaObject As Object)
  368.     WindowsMediaPlayer1.URL = AlarmFile
  369.     WindowsMediaPlayer1.Controls.play
  370.     MsgBox "Couldn't connect to internet !"
  371. End Sub
  372. Private Sub WindowsMediaPlayer1_PlayStateChange(ByVal NewState As Long)
  373.     Select Case NewState
  374.     Case wmppsMediaEnded
  375.         WindowsMediaPlayer1.Controls.stop
  376.     Case wmppsReady
  377.         WindowsMediaPlayer1.Controls.stop
  378.     Case wmppsStopped
  379.         SetMasterVolume_Value OgVol
  380.         WindowsMediaPlayer1.URL = AlarmStream
  381.     End Select
  382. End Sub
  383. Public Sub PlayItLoud()
  384.     Dim eType As eConnectionType
  385.     Dim sName As String
  386.     If WindowsMediaPlayer1.playState = wmppsStopped Or WindowsMediaPlayer1.playState = wmppsUndefined Or WindowsMediaPlayer1.playState = wmppsReady Then
  387.         If GetSetting("Streaming Radio Alarm Clock", "Settings", "RadioStream", "1") = 0 Or InternetConnected(sName, eType) = False Or AlarmStream = vbNullString Then
  388.             If AlarmFile = vbNullString Then MsgBox "Please choose a alarm sound file !": Exit Sub
  389.             OgVol = GetMasterVolume_Value
  390.             MasterVolume_Mute True, False
  391.             SetMasterVolume_Value "90"
  392.             WindowsMediaPlayer1.URL = AlarmFile
  393.         Else
  394.             OgVol = GetMasterVolume_Value
  395.             MasterVolume_Mute True, False
  396.             SetMasterVolume_Value "90"
  397.             WindowsMediaPlayer1.URL = AlarmStream
  398.         End If
  399.         WindowsMediaPlayer1.Controls.play
  400.     Else
  401.         WindowsMediaPlayer1.Controls.stop
  402.         SetMasterVolume_Value OgVol
  403.     End If
  404. End Sub
  405. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  406.     Dim Message As Long
  407.     Message = X / Screen.TwipsPerPixelX
  408.     Select Case Message
  409.     Case WM_RBUTTONUP
  410.         SetForegroundWindow Me.hwnd
  411.         PopupMenu mnuSysTray
  412.     Case WM_LBUTTONUP
  413.         Me.Show
  414.     End Select
  415. End Sub
  416.