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

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "TimeFrame"
  5.    ClientHeight    =   2955
  6.    ClientLeft      =   1200
  7.    ClientTop       =   1545
  8.    ClientWidth     =   2265
  9.    Height          =   3360
  10.    Icon            =   TIMEFRAM.FRX:0000
  11.    Left            =   1140
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    ScaleHeight     =   2955
  16.    ScaleWidth      =   2265
  17.    Top             =   1200
  18.    Width           =   2385
  19.    Begin CommandButton btnEnd 
  20.       Caption         =   "End"
  21.       Height          =   375
  22.       Left            =   1320
  23.       TabIndex        =   6
  24.       Top             =   2160
  25.       Width           =   855
  26.    End
  27.    Begin Timer Timer1 
  28.       Interval        =   1000
  29.       Left            =   960
  30.       Top             =   2160
  31.    End
  32.    Begin CommandButton btnOk 
  33.       Caption         =   "Ok"
  34.       Height          =   375
  35.       Left            =   120
  36.       TabIndex        =   1
  37.       Top             =   2160
  38.       Width           =   855
  39.    End
  40.    Begin Frame Frame1 
  41.       Caption         =   "Clock Position"
  42.       Height          =   975
  43.       Left            =   120
  44.       TabIndex        =   7
  45.       Top             =   960
  46.       Width           =   2055
  47.       Begin OptionButton rbtnRight 
  48.          Caption         =   "on the Right"
  49.          Height          =   255
  50.          Left            =   120
  51.          TabIndex        =   9
  52.          Top             =   600
  53.          Width           =   1815
  54.       End
  55.       Begin OptionButton rbtnLeft 
  56.          Caption         =   "on the Left"
  57.          Height          =   255
  58.          Left            =   120
  59.          TabIndex        =   8
  60.          Top             =   360
  61.          Value           =   -1  'True
  62.          Width           =   1815
  63.       End
  64.    End
  65.    Begin HScrollBar scrInterval 
  66.       Height          =   255
  67.       Left            =   120
  68.       Max             =   10
  69.       Min             =   1
  70.       TabIndex        =   2
  71.       Top             =   600
  72.       Value           =   1
  73.       Width           =   2055
  74.    End
  75.    Begin Label Label3 
  76.       Alignment       =   2  'Center
  77.       Caption         =   "by  J. Br
  78. uchi"
  79.       FontBold        =   0   'False
  80.       FontItalic      =   0   'False
  81.       FontName        =   "MS Sans Serif"
  82.       FontSize        =   8.25
  83.       FontStrikethru  =   0   'False
  84.       FontUnderline   =   0   'False
  85.       Height          =   255
  86.       Left            =   120
  87.       TabIndex        =   5
  88.       Top             =   2640
  89.       Width           =   2055
  90.    End
  91.    Begin Label Label2 
  92.       Caption         =   "sec"
  93.       Height          =   255
  94.       Left            =   1800
  95.       TabIndex        =   4
  96.       Top             =   240
  97.       Width           =   375
  98.    End
  99.    Begin Label lblInterval 
  100.       BorderStyle     =   1  'Fixed Single
  101.       Height          =   255
  102.       Left            =   1200
  103.       TabIndex        =   3
  104.       Top             =   240
  105.       Width           =   375
  106.    End
  107.    Begin Label Label1 
  108.       Caption         =   "Interval"
  109.       Height          =   255
  110.       Left            =   120
  111.       TabIndex        =   0
  112.       Top             =   240
  113.       Width           =   855
  114.    End
  115. ' TIMEFRAME by J. Braeuchi
  116. ' Display current time in caption of active Window
  117. Const init_timer% = 5           ' Initial Interval (sec)
  118. Dim parentwin As Integer        ' Handle of Parent
  119. Dim holdwin As Integer          ' Handle of Old
  120. Dim capold As String            ' Caption of Old
  121. Sub btnEnd_Click ()
  122. '   End Program
  123.     Unload Form1
  124. End Sub
  125. Sub btnOk_Click ()
  126. '   Minimize Program
  127.     Form1.WindowState = 1
  128. End Sub
  129. Sub Form_Load ()
  130.     parentwin = GetActiveWindow()
  131.     holdwin = 0
  132.     capold = ""
  133.     scrInterval.Value = init_timer%
  134.     lblInterval.caption = Str$(init_timer%)
  135.     Timer1.interval = 1000 * init_timer%      ' Milliseconds
  136. End Sub
  137. Sub Form_Resize ()
  138. '   Switch to parent if minimized
  139.     If Form1.WindowState = 1 Then
  140.       dummy% = SetActiveWindow(parentwin)
  141.     End If
  142. End Sub
  143. Sub Form_Unload (Cancel As Integer)
  144. '   Disable Timer
  145.     Timer1.interval = 0
  146.     If holdwin <> 0 Then
  147.        Call SetWindowText(holdwin, capold)  ' Restore Caption
  148.     End If
  149. End Sub
  150. Sub scrInterval_Change ()
  151. '   Interval Scrollbar Change
  152.     lblInterval.caption = Str$(scrInterval.Value)
  153.     Timer1.interval = scrInterval.Value * 1000
  154. End Sub
  155. Sub Timer1_Timer ()
  156. '   Add Current Time to Caption of Active Window
  157.     Dim hawin As Integer
  158.     Dim caption As String
  159.     Dim caplen As Integer
  160. ' Handle of Active Window , exit if own handle
  161.     hawin = GetActiveWindow()
  162.     If hawin = Form1.hWnd Then
  163.        Exit Sub
  164.     End If
  165. ' Update Time if still same Window active
  166. ' Choose wether Clock is displayed left or right of caption
  167.     If hawin = holdwin Then
  168.        If rbtnLeft.Value = True Then
  169.           caption = "<" + Time$ + ">  " + capold
  170.        Else
  171.           caption = capold + "  <" + Time$ + ">"
  172.        End If
  173.        
  174.        Call SetWindowText(holdwin, caption)
  175.        Exit Sub
  176.     Else
  177.        If holdwin <> 0 Then
  178.           Call SetWindowText(holdwin, capold)  ' Restore Caption
  179.        End If
  180. ' Get Caption of active Window
  181.        caplen = GetWindowTextLength(hawin)
  182.        capold = Space$(caplen + 1)           ' +1 for terminating 0
  183.        dummy% = GetWindowText(hawin, capold, caplen + 1)
  184.        capold = Left$(capold, caplen)        ' cut terminating 0
  185.        holdwin = hawin
  186.        Timer1_Timer                          ' immediate display
  187.     End If
  188. End Sub
  189.