home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vb_clk2 / frm_clk.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  7.2 KB  |  199 lines

  1. VERSION 2.00
  2. Begin Form FRM_Clock 
  3.    AutoRedraw      =   -1  'True
  4.    BorderStyle     =   0  'None
  5.    ClientHeight    =   240
  6.    ClientLeft      =   7260
  7.    ClientTop       =   5790
  8.    ClientWidth     =   1560
  9.    ControlBox      =   0   'False
  10.    Height          =   645
  11.    Icon            =   FRM_CLK.FRX:0000
  12.    Left            =   7200
  13.    LinkMode        =   1  'Source
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   240
  18.    ScaleWidth      =   1560
  19.    Top             =   5445
  20.    Width           =   1680
  21.    Begin Timer Timer1 
  22.       Interval        =   500
  23.       Left            =   0
  24.       Top             =   0
  25.    End
  26. DefInt A-Z
  27. Dim IniFile$
  28. Dim MyRect As RECT
  29. Dim AllowFormToMove
  30. Dim MStartX
  31. Dim MStartY
  32. Dim ClassName As String * 15
  33. Dim cn$
  34. Dim Wnd As Integer
  35. Sub DisplayInfo ()
  36.     If IsFloat Then
  37.         Wnd = WindowFromPoint(15, 15)
  38.         If (Wnd > 0) And (Wnd <> FRM_Clock.hWnd) Then
  39.             b% = GetClassName(Wnd, ClassName, 15)
  40.             cn$ = TrimZeroTerm(ClassName)
  41.             If cn$ <> "BlankerClass" Then GetWindowRect Wnd, MyRect
  42.             
  43.             If (MyRect.Left = 0) And (MyRect.Top = 0) And (cn$ = "NFMWClass" Or cn$ = "#32769") Then
  44.                 MyRect.Right = MyRect.Right + 4
  45.                 MyRect.Top = -4
  46.             End If
  47.             
  48.             FRM_Clock.Left = Pixels_To_Twips(MyRect.Right) - (FRM_Clock.Width + 700)
  49.             FRM_Clock.Top = Pixels_To_Twips(MyRect.Top) + 75
  50.         End If
  51.     End If
  52.     msg$ = ""
  53.     For X% = 1 To MaxItems
  54.         msg$ = msg$ + GetInfo(DispInfo(X%))
  55.     Next X%
  56.     msg$ = RTrim$(msg$)
  57.     FRM_Clock.Backcolor = bColour
  58.     FRM_Clock.ForeColor = fColour
  59.     FRM_Clock.CurrentX = ((FRM_Clock.Width - TextWidth(msg$)) / 2)
  60.     FRM_Clock.CurrentY = ((FRM_Clock.Height - TextHeight(msg$)) / 2)
  61.     FRM_Clock.Print msg$
  62. End Sub
  63. Sub Form_DblClick ()
  64.     ShowOptions
  65. End Sub
  66. Sub Form_Load ()
  67.     Const TempLen = 250
  68.     Dim TempStr As String * TempLen
  69.         
  70.     On_top% = SetWindowPos(FRM_Clock.hWnd, -1, 0, 0, 0, 0, &H2 Or &H1 Or &H40 Or &H10)
  71.     sm% = FRM_Clock.scalemode
  72.     FRM_Clock.scalemode = 1
  73.     Scale_Twip = FRM_Clock.ScaleWidth
  74.     FRM_Clock.scalemode = 3
  75.     Scale_Pixel = FRM_Clock.ScaleWidth
  76.     FRM_Clock.scalemode = sm%
  77.     ' get windows directory for INI file
  78.     uh% = GetWindowsDirectory(TempStr, TempLen)
  79.     IniFile$ = TrimZeroTerm(TempStr)
  80.     If Right$(IniFile$, 1) <> "\" Then IniFile$ = IniFile$ + "\"
  81.     IniFile$ = IniFile$ + "VBCLOCK.INI"
  82.     ' get & set position from INI file
  83.     FRM_Clock.Top = GetPrivateProfileInt("Position", "Top", Int(Screen.Height * .003), IniFile$)
  84.     FRM_Clock.Left = GetPrivateProfileInt("Position", "Left", Int(Screen.Width * .71), IniFile$)
  85.     IsFloat = GetPrivateProfileInt("Position", "Floating", True, IniFile$)
  86.     If IsFloat And (FRM_Clock.Left <= Pixels_To_Twips(15)) And (FRM_Clock.Top <= Pixels_To_Twips(15)) Then FRM_Clock.Left = Pixels_To_Twips(20)
  87.     ' get & set colours from INI file
  88.     uh% = GetPrivateProfileString("Colour", "Background", Format$(ACTIVE_TITLE_BAR), TempStr, TempLen, IniFile$)
  89.     bColour = Val(TempStr)
  90.     uh% = GetPrivateProfileString("Colour", "Foreground", Format$(INACTIVE_TITLE_BAR), TempStr, TempLen, IniFile$)
  91.     fColour = Val(TempStr)
  92.     ' get & set typeface
  93.     uh% = GetPrivateProfileString("Typeface", "Font", "MS Sans Serif", TempStr, TempLen, IniFile$)
  94.     DispFont = TrimZeroTerm(TempStr)
  95.     uh% = GetPrivateProfileString("Typeface", "Fontsize", "8.25", TempStr, TempLen, IniFile$)
  96.     DispFontSize = Val(TempStr)
  97.     ' get & set display
  98.     DispInfo(1) = GetPrivateProfileInt("Display", "Info1", 1, IniFile$)
  99.     DispInfo(2) = GetPrivateProfileInt("Display", "Info2", 2, IniFile$)
  100.     DispInfo(3) = GetPrivateProfileInt("Display", "Info3", 5, IniFile$)
  101.     DispInfo(4) = GetPrivateProfileInt("Display", "Info4", 7, IniFile$)
  102.     For X% = 5 To MaxItems
  103.         nm$ = "Info" + Format$(X%)
  104.         DispInfo(X%) = GetPrivateProfileInt("Display", nm$, 6, IniFile$)
  105.     Next X%
  106.     ' get & set alarm
  107.     IsAlarm = False
  108.     uh% = GetPrivateProfileString("Alarm", "Time", "0", TempStr, TempLen, IniFile$)
  109.     AlarmTime = Val(TempStr)
  110.     If AlarmTime > Now Then
  111.         IsAlarm = True
  112.         uh% = GetPrivateProfileString("Alarm", "Message", "", TempStr, TempLen, IniFile$)
  113.         AlarmMessage = TrimZeroTerm(TempStr)
  114.     End If
  115.     SetForm
  116.     DisplayInfo
  117. End Sub
  118. Sub Form_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  119.   If (Button And LEFT_BUTTON) > 0 Then
  120.     AllowFormToMove = True
  121.     MStartX = X
  122.     MStartY = Y
  123.     MousePointer = SIZE_POINTER
  124.   End If
  125. End Sub
  126. Sub Form_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  127.   If AllowFormToMove Then Move FRM_Clock.Left + (X - MStartX), FRM_Clock.Top + (Y - MStartY)
  128. End Sub
  129. Sub Form_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  130.   RButt = (Button And RIGHT_BUTTON) > 0
  131.   LButt = (Button And LEFT_BUTTON) > 0
  132.   Ctrl = (Shift And CTRL_MASK) > 0
  133.   If LButt Then
  134.     AllowFormToMove = False
  135.     MousePointer = DEFAULT
  136.   ElseIf RButt Then
  137.     Select Case Ctrl
  138.       Case False
  139.         ShowOptions
  140.       Case True
  141.         End
  142.     End Select
  143.   End If
  144. End Sub
  145. Sub Form_Unload (Cancel As Integer)
  146.     WriteProfile
  147. End Sub
  148. Sub SetForm ()
  149.     FRM_Clock.FontName = DispFont
  150.     FRM_Clock.FontSize = DispFontSize
  151.     FRM_Clock.FontBold = True
  152.     msg$ = ""
  153.     For X% = 1 To MaxItems
  154.         msg$ = msg$ + GetInfo(DispInfo(X%))
  155.     Next X%
  156.     msg$ = RTrim$(msg$)
  157.     FRM_Clock.Width = TextWidth(msg$) * 1.05
  158.     FRM_Clock.Height = TextHeight(msg$) * 1.15
  159. End Sub
  160. Sub ShowOptions ()
  161.     Timer1.Enabled = False
  162.     FRM_Opts.Show 1
  163.     Timer1.Enabled = True
  164.     SetForm
  165.     WriteProfile
  166.     DisplayInfo
  167. End Sub
  168. Sub Timer1_Timer ()
  169.     DisplayInfo
  170.     If IsAlarm Then
  171.         If AlarmTime <= Now Then
  172.             MessageBeep (48)
  173.             If AlarmMessage = "" Then AlarmMessage = "It's that time!"
  174.             MsgBox AlarmMessage, 48, "Alarm"
  175.             IsAlarm = False
  176.             FRM_Opts.CHK_Alarm.Value = 0
  177.         End If
  178.     End If
  179. End Sub
  180. Sub WriteProfile ()
  181.   uh = WritePrivateProfileString("Colour", "Background", Format$(bColour), IniFile$)
  182.   uh = WritePrivateProfileString("Colour", "Foreground", Format$(fColour), IniFile$)
  183.   uh = WritePrivateProfileString("Typeface", "Font", DispFont, IniFile$)
  184.   uh = WritePrivateProfileString("Typeface", "Fontsize", Format$(DispFontSize), IniFile$)
  185.   uh = WritePrivateProfileString("Position", "Floating", Format$(IsFloat), IniFile$)
  186.   If Not IsFloat Then
  187.     uh = WritePrivateProfileString("Position", "Top", Format$(FRM_Clock.Top), IniFile$)
  188.     uh = WritePrivateProfileString("Position", "Left", Format$(FRM_Clock.Left), IniFile$)
  189.   End If
  190.   If IsAlarm Then
  191.     uh = WritePrivateProfileString("Alarm", "Time", Format$(AlarmTime), IniFile$)
  192.     uh = WritePrivateProfileString("Alarm", "Message", AlarmMessage, IniFile$)
  193.   End If
  194.   For X% = 1 To MaxItems
  195.     nm$ = "Info" + Format$(X%)
  196.     uh = WritePrivateProfileString("Display", nm$, Format$(DispInfo(X%)), IniFile$)
  197.   Next X%
  198. End Sub
  199.