home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / boxes / ttcode / thetime.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-25  |  47.7 KB  |  1,125 lines

  1. VERSION 2.00
  2. Begin Form thetime 
  3.    BackColor       =   &H00FFFFFF&
  4.    Caption         =   "theTime"
  5.    ClientHeight    =   1335
  6.    ClientLeft      =   1845
  7.    ClientTop       =   1995
  8.    ClientWidth     =   4320
  9.    ClipControls    =   0   'False
  10.    Height          =   1740
  11.    Icon            =   THETIME.FRX:0000
  12.    KeyPreview      =   -1  'True
  13.    Left            =   1785
  14.    LinkTopic       =   "Form2"
  15.    ScaleHeight     =   89
  16.    ScaleMode       =   3  'Pixel
  17.    ScaleWidth      =   288
  18.    Top             =   1650
  19.    Visible         =   0   'False
  20.    Width           =   4440
  21.    Begin MsgBlaster MsgBlaster1 
  22.       Prop8           =   "Click on ""..."" for the About Box ---->"
  23.    End
  24.    Begin CommonDialog CMDialog1 
  25.       Left            =   0
  26.       Top             =   360
  27.    End
  28.    Begin Timer Timer1 
  29.       Enabled         =   0   'False
  30.       Interval        =   1000
  31.       Left            =   0
  32.       Top             =   0
  33.    End
  34.    Begin PZLabel TimePan 
  35.       Height          =   1065
  36.       Left            =   870
  37.       PictureStyle    =   3  'Tiled
  38.       TabIndex        =   0
  39.       Top             =   90
  40.       Visible         =   0   'False
  41.       Width           =   2535
  42.    End
  43. Option Explicit
  44. '*******************************************************
  45. '*                                                     *
  46. '*   theTime, a mildly interesting Windows 3.x clock   *
  47. '*   Written by Visual Bits                            *
  48. '*   Copyright 
  49.  1995                                  *
  50. '*                                                     *
  51. '*   This software and any documentation are supplied  *
  52. '*   "AS IS".  The author makes no warranty of any     *
  53. '*   kind, either express or implied, with respect to  *
  54. '*   this software and accompanying documentation.  In *
  55. '*   no event shall the author of this software be     *
  56. '*   liable for any damages arising out of the use of  *
  57. '*   this product. Your use of this software indicates *
  58. '*   that you have read and agreed to these terms.     *
  59. '*                                                     *
  60. '*   Other then that, you may use this program's       *
  61. '*   source code in any way you find useful.           *
  62. '*                                                     *
  63. '*                                                     *
  64. '*******************************************************
  65. ' first identify yourself
  66. Const AppName = "theTime"
  67. Const Version = "2.5"
  68. Const Company = "Visual Bits"
  69. Const CopyRight = "Copyright 
  70.  1995"
  71. ' variables used throughout this form
  72. Dim MyRect As RECT
  73. Dim BorderSize As Integer, TitleSize As Integer
  74. Dim dtw As Integer, dth As Integer ' short for desktop width & height
  75. Dim TopMost As Integer
  76. Dim Border As Integer, OldBorder As Integer
  77. Dim Stuck As Integer
  78. Dim Zoomed As Integer
  79. Dim hMyMenu As Integer
  80. ' Background modes
  81. Const BM_SOLID = 0
  82. Const BM_BITMAP = 1
  83. Const BM_TRANSPARENT = 2
  84. Dim BackMode As Integer
  85. Dim BackBmp As String
  86. Dim ErasingBackgrnd As Integer
  87. Dim InitFile As String
  88. Dim nl As String
  89. ' bit mask for date and time menu options
  90. Dim DateOption As Integer
  91. Const DO_DF = &H7
  92. Const DO_MT = &H10
  93. Const DO_DN = &H20
  94. Const DO_FM = &H40
  95. Const DO_FY = &H80
  96. Const DO_1L = &H100
  97. ' bit mask for Font options
  98. Const FO_3D = &H7
  99. Const FO_BD = &H10
  100. Const FO_IT = &H20
  101. Const FO_ST = &H40
  102. Const FO_UL = &H80
  103. ' save the last time and date displayed
  104. Dim sTime As String, sDate As String
  105. ' the so called font factor, used to guess how large fonts should be
  106. Dim FontFact As Single
  107. Sub AdjustForm (f As Form)
  108. '*******************************************************
  109. '*                                                     *
  110. '*   Adjust the position of a form to be either just   *
  111. '*   above the main form or just below it, but never   *
  112. '*   off the screen.                                   *
  113. '*                                                     *
  114. '*******************************************************
  115.     Dim fLeft As Integer, ftop As Integer, gap As Integer
  116.     Dim i As Integer
  117.     gap = BorderSize * Tpx
  118.     ' put the horizontal position in the middle of the time
  119.     fLeft = Left - (f.Width - Width) \ 2
  120.     ' but not off the screen
  121.     i = Screen.Width - f.Width - gap
  122.     If fLeft > i Then fLeft = i
  123.     If fLeft < gap Then fLeft = gap
  124.     ' put the vertical postion above or below the time
  125.     If Top + Height \ 2 > Screen.Height \ 2 Then
  126.         ftop = Top - f.Height - gap
  127.     Else
  128.         ftop = Top + Height + gap
  129.     End If
  130.     ' or in the middle of the time if off the screen
  131.     i = Screen.Height - f.Height - gap
  132.     If ftop < gap Or ftop > i Then
  133.         ftop = Top + (Height - f.Height) \ 2
  134.     End If
  135.     f.Move fLeft, ftop
  136. End Sub
  137. Sub CheckBackItem ()
  138. '*******************************************************
  139. '*                                                     *
  140. '*   Check the background mode menu items and set      *
  141. '*   BackMode accordingly.                             *
  142. '*                                                     *
  143. '*******************************************************
  144.     Dim hSubMenu As Integer
  145.     hSubMenu = GetSubMenu(hMyMenu, 4)
  146.     CheckMenuItem hSubMenu, BackMode, MF_BYPOSITION Or MF_CHECKED
  147.     CheckMenuItem hSubMenu, (BackMode Xor 3) And BM_BITMAP, MF_BYPOSITION Or MF_UNCHECKED
  148.     CheckMenuItem hSubMenu, (BackMode Xor 3) And BM_TRANSPARENT, MF_BYPOSITION Or MF_UNCHECKED
  149. End Sub
  150. Function CreateMyMenu () As Integer
  151. '*******************************************************
  152. '*                                                     *
  153. '*   This creates the menu that is inserted into the   *
  154. '*   system menu and pops up whenever the right button *
  155. '*   is clicked.  Note that using a VB created menu    *
  156. '*   is not possible since a VB menu must be visible   *
  157. '*   on the form menu line to be popped up.            *
  158. '*                                                     *
  159. '*******************************************************
  160.     Dim hMenu As Integer, hSub1Menu As Integer, hSub2Menu As Integer
  161.     Dim checked As Integer
  162.     hMenu = CreateMenu()
  163.     checked = 0: If TopMost = HWND_TOPMOST Then checked = MF_CHECKED
  164.     AppendMenu hMenu, MF_STRING Or checked, 100, ("&Keep On Top")
  165.     checked = 0: If Border Then checked = MF_CHECKED
  166.     AppendMenu hMenu, MF_STRING Or checked, 200, ("&Title Bar")
  167.     checked = 0: If Stuck Then checked = MF_CHECKED
  168.     AppendMenu hMenu, MF_STRING Or checked, 700, ("&Stuck")
  169.     AppendMenu hMenu, MF_SEPARATOR, 0, 0&
  170.     hSub1Menu = CreateMenu()
  171.     checked = 0: If BackMode = BM_SOLID Then checked = MF_CHECKED
  172.     AppendMenu hSub1Menu, MF_STRING Or checked, 310, ("&Solid Background")
  173.     checked = 0: If BackMode = BM_BITMAP Then checked = MF_CHECKED
  174.     AppendMenu hSub1Menu, MF_STRING Or checked, 320, ("&Load Bitmap...")
  175.     checked = 0: If BackMode = BM_TRANSPARENT Then checked = MF_CHECKED
  176.     AppendMenu hSub1Menu, MF_STRING Or checked, 330, ("&Transparent")
  177.     AppendMenu hSub1Menu, MF_SEPARATOR, 0, 0&
  178.     AppendMenu hSub1Menu, MF_STRING, 340, ("&Background Color...")
  179.     AppendMenu hMenu, MF_POPUP, hSub1Menu, ("&Background")
  180.     hSub1Menu = CreateMenu()
  181.     AppendMenu hSub1Menu, MF_STRING, 420, ("&Font...")
  182.     hSub2Menu = CreateMenu()
  183.     checked = 0: If TimePan.Font3D = 0 Then checked = MF_CHECKED
  184.     AppendMenu hSub2Menu, MF_STRING Or checked, 410, ("&1 None")
  185.     checked = 0: If TimePan.Font3D = 1 Then checked = MF_CHECKED
  186.     AppendMenu hSub2Menu, MF_STRING Or checked, 411, ("&2 Block Left")
  187.     checked = 0: If TimePan.Font3D = 2 Then checked = MF_CHECKED
  188.     AppendMenu hSub2Menu, MF_STRING Or checked, 412, ("&3 Block Right")
  189.     checked = 0: If TimePan.Font3D = 3 Then checked = MF_CHECKED
  190.     AppendMenu hSub2Menu, MF_STRING Or checked, 413, ("&4 Drop Left")
  191.     checked = 0: If TimePan.Font3D = 4 Then checked = MF_CHECKED
  192.     AppendMenu hSub2Menu, MF_STRING Or checked, 414, ("&5 Drop Right")
  193.     AppendMenu hSub1Menu, MF_POPUP, hSub2Menu, ("Font &3D Options")
  194.     hSub2Menu = CreateMenu()
  195.     AppendMenu hSub2Menu, MF_STRING, 418, ("&Increase")
  196.     AppendMenu hSub2Menu, MF_STRING, 416, ("&Decrease")
  197.     AppendMenu hSub2Menu, MF_STRING, 419, ("I&ncrease More")
  198.     AppendMenu hSub2Menu, MF_STRING, 415, ("D&ecrease More")
  199.     AppendMenu hSub1Menu, MF_POPUP, hSub2Menu, ("Font 3D &Sizes")
  200.     AppendMenu hSub1Menu, MF_STRING, 425, ("Font 3D &Color...")
  201.     AppendMenu hSub1Menu, MF_SEPARATOR, 0, 0&
  202.     checked = 0: If DateOption And DO_MT Then checked = MF_CHECKED
  203.     AppendMenu hSub1Menu, MF_STRING Or checked, 430, ("Military &Time")
  204.     checked = 0: If DateOption And DO_DN Then checked = MF_CHECKED
  205.     AppendMenu hSub1Menu, MF_STRING Or checked, 440, ("Full &Day")
  206.     checked = 0: If DateOption And DO_FM Then checked = MF_CHECKED
  207.     AppendMenu hSub1Menu, MF_STRING Or checked, 450, ("Full &Month")
  208.     checked = 0: If DateOption And DO_FY Then checked = MF_CHECKED
  209.     AppendMenu hSub1Menu, MF_STRING Or checked, 460, ("Full &Year")
  210.     checked = 0: If DateOption And DO_1L Then checked = MF_CHECKED
  211.     AppendMenu hSub1Menu, MF_STRING Or checked, 465, ("One &Line")
  212.     AppendMenu hSub1Menu, MF_SEPARATOR, 0, 0&
  213.     hSub2Menu = CreateMenu()
  214.     checked = 0: If (DateOption And DO_DF) = 0 Then checked = MF_CHECKED
  215.     AppendMenu hSub2Menu, MF_STRING Or checked, 470, ("&1 No Date")
  216.     checked = 0: If (DateOption And DO_DF) = 1 Then checked = MF_CHECKED
  217.     AppendMenu hSub2Menu, MF_STRING Or checked, 471, ("&2 m/d/y")
  218.     checked = 0: If (DateOption And DO_DF) = 2 Then checked = MF_CHECKED
  219.     AppendMenu hSub2Menu, MF_STRING Or checked, 472, ("&3 dd-mmm-y")
  220.     checked = 0: If (DateOption And DO_DF) = 3 Then checked = MF_CHECKED
  221.     AppendMenu hSub2Menu, MF_STRING Or checked, 473, ("&4 mmm dd, y")
  222.     checked = 0: If (DateOption And DO_DF) = 4 Then checked = MF_CHECKED
  223.     AppendMenu hSub2Menu, MF_STRING Or checked, 474, ("&4 mmm dd")
  224.     AppendMenu hSub1Menu, MF_POPUP, hSub2Menu, ("Date &Options")
  225.     AppendMenu hMenu, MF_POPUP, hSub1Menu, ("&Font && Time/Date Format")
  226.     AppendMenu hMenu, MF_STRING, 500, ("Bevel && Border &Options...")
  227.     AppendMenu hMenu, MF_SEPARATOR, 0, 0&
  228.     AppendMenu hMenu, MF_STRING, 600, ("&About...")
  229.     AppendMenu hMenu, MF_SEPARATOR, 0, 0&
  230.     AppendMenu hMenu, MF_STRING, 900, ("E&xit")
  231.     CreateMyMenu = hMenu
  232. End Function
  233. Sub EraseBackGrnd ()
  234. '*******************************************************
  235. '*                                                     *
  236. '*   When theTime's form is transparent this routine   *
  237. '*   deals with erasing the background and making it   *
  238. '*   visible again.  Since the normal EraseBackgrnd    *
  239. '*   message is captured the VB form never paints.     *
  240. '*   Therefore by painting only the foreground of the  *
  241. '*   Pizazz control the illusion of transparancy is    *
  242. '*   created.  The big trick is whenever the form is   *
  243. '*   moved or resized or painted you need to make the  *
  244. '*   form briefly invisible so the real background is  *
  245. '*   updated, then make the form visible and paint     *
  246. '*   the foreground.  This routine does just that.     *
  247. '*                                                     *
  248. '*   ErasingBackgrnd is a state variable.              *
  249. '*   0 : hide the window                               *
  250. '*   -1: busy, go away                                 *
  251. '*   1: window is hidden, so show it                   *
  252. '*                                                     *
  253. '*******************************************************
  254.     Dim i As Integer
  255.     If IsIconic(hWnd) = 0 And BackMode = BM_TRANSPARENT Then
  256.         If ErasingBackgrnd = 0 Then
  257.             ErasingBackgrnd = -1 ' working...
  258.             ShowWindow hWnd, SW_HIDE
  259.             DoEvents
  260.             ErasingBackgrnd = 1
  261.         ElseIf ErasingBackgrnd = 1 Then
  262.             ErasingBackgrnd = -1 ' working...
  263.             i = SW_SHOWNA
  264.             If Stuck Then i = SW_SHOWNOACTIVATE
  265.             ShowWindow hWnd, i
  266.             DoEvents
  267.             ErasingBackgrnd = 0 ' all done
  268.         End If
  269.     End If
  270. End Sub
  271. Sub Form_KeyDown (keycode As Integer, Shift As Integer)
  272. '*******************************************************
  273. '*                                                     *
  274. '*   Handle the keyboard from here.  Allow the form    *
  275. '*   to be moved around the screen using the arrow     *
  276. '*   and shift keys.                                   *
  277. '*                                                     *
  278. '*******************************************************
  279.     Dim x As Integer, y As Integer, MyW As Integer, MyH As Integer
  280.     If IsZoomed(hWnd) Or Stuck Then Exit Sub
  281.     GetWindowRect hWnd, MyRect
  282.     x = MyRect.Left
  283.     y = MyRect.Top
  284.     MyW = MyRect.Right - MyRect.Left
  285.     MyH = MyRect.Bottom - MyRect.Top
  286.     Select Case keycode
  287.     Case KEY_LEFT
  288.         If Shift = 1 Then
  289.             x = 0
  290.         Else
  291.             x = x - 10
  292.         End If
  293.     Case KEY_UP
  294.         If Shift = 1 Then
  295.             y = 0
  296.         Else
  297.             y = y - 10
  298.         End If
  299.     Case KEY_RIGHT
  300.         If Shift = 1 Then
  301.             x = dtw - MyW
  302.         Else
  303.             x = x + 10
  304.         End If
  305.     Case KEY_DOWN
  306.         If Shift = 1 Then
  307.             y = dth - MyH
  308.         Else
  309.             y = y + 10
  310.         End If
  311.     End Select
  312.     SetWindowPos hWnd, 0, x, y, 0, 0, SWP_NOSIZE
  313. End Sub
  314. Sub Form_Load ()
  315. '*******************************************************
  316. '*                                                     *
  317. '*   This is the starting point.  Setup the global     *
  318. '*   variables and the message blaster control, read   *
  319. '*   the ini file, show the form, and start the timer. *
  320. '*                                                     *
  321. '*******************************************************
  322.     Dim hSysMenu As Integer
  323.     Dim aRect As RECT
  324.     Dim s As String
  325.     ' Initialize global variables
  326.     Set CD = CmDialog1
  327.     TopMost = HWND_NOTOPMOST
  328.     Border = True
  329.     DateOption = 1
  330.     nl = Chr$(13) & Chr$(10)
  331.     FontFact = 1#
  332.     InitFile = app.Path & "\theTime.ini"
  333.     ErasingBackgrnd = True
  334.     ' Get the DeskTop (Screen) and non-client dimensions
  335.     GetClientRect GetDeskTopWindow(), aRect
  336.     dtw = aRect.Right
  337.     dth = aRect.Bottom
  338.     Tpx = Screen.TwipsPerPixelX: Tpy = Screen.TwipsPerPixelY
  339.     BorderSize = (Width \ Tpx - ScaleWidth)
  340.     TitleSize = (Height \ Tpy - ScaleHeight) - BorderSize
  341.     BorderSize = BorderSize \ 2
  342.     ' Setup the Message handling
  343.     MsgBlaster1.hWndTarget = hWnd
  344.     MsgBlaster1.MsgList(0) = WM_NCHITTEST
  345.     MsgBlaster1.MsgPassage(0) = -1 ' preprocess
  346.     MsgBlaster1.MsgList(1) = WM_RBUTTONDOWN
  347.     MsgBlaster1.MsgPassage(1) = 0 ' eat it
  348.     MsgBlaster1.MsgList(2) = WM_LBUTTONDBLCLK
  349.     MsgBlaster1.MsgPassage(2) = 0 ' eat it
  350.     MsgBlaster1.MsgList(3) = WM_NCRBUTTONDOWN
  351.     MsgBlaster1.MsgPassage(3) = 0 ' eat it
  352.     MsgBlaster1.MsgList(4) = WM_NCLBUTTONDBLCLK
  353.     MsgBlaster1.MsgPassage(4) = 0 ' eat it
  354.     MsgBlaster1.MsgList(5) = WM_COMMAND
  355.     MsgBlaster1.MsgPassage(5) = 1 ' post process
  356.     MsgBlaster1.MsgList(6) = WM_SYSCOMMAND
  357.     MsgBlaster1.MsgPassage(6) = 1 ' post process
  358.     MsgBlaster1.MsgList(7) = WM_DROPFILES
  359.     MsgBlaster1.MsgPassage(7) = 1 ' post process
  360.     MsgBlaster1.MsgList(8) = WM_MOUSEACTIVATE
  361.     MsgBlaster1.MsgPassage(8) = 0' eat it
  362.     MsgBlaster1.MsgList(9) = WM_ERASEBKGND
  363.     MsgBlaster1.MsgPassage(9) = 0 'eat it
  364.     MsgBlaster1.MsgList(10) = WM_MOVE
  365.     MsgBlaster1.MsgPassage(10) = 1 'post process
  366.     LoadInitFile
  367.     DragAcceptFiles hWnd, True
  368.     ' create our menu and add it to the system menu
  369.     hMyMenu = CreateMyMenu()
  370.     hSysMenu = GetSystemMenu(hWnd, 0)
  371.     AppendMenu hSysMenu, MF_SEPARATOR, 0, 0&
  372.     s = AppName & " Options"
  373.     AppendMenu hSysMenu, MF_POPUP, hMyMenu, (s)
  374.     SetBackMode
  375.     ShowForm
  376.     Timer1_Timer
  377.     DoEvents
  378.     ErasingBackgrnd = False
  379.     OldBorder = Border
  380.     Timer1.Enabled = True
  381. End Sub
  382. Sub Form_Resize ()
  383. '*******************************************************
  384. '*                                                     *
  385. '*   When a form resizes and it's an icon put the time *
  386. '*   in the caption.  When borders come or go we       *
  387. '*   generally don't need to handle the resulting      *
  388. '*   resize, unless the form has been maxed (zoomed).  *
  389. '*   Otherwise, reset the caption, resize the font,    *
  390. '*   and size the panel.  Oh, call EraseBackGrnd in    *
  391. '*   case the form is transparent.                     *
  392. '*                                                     *
  393. '*******************************************************
  394.     If IsIconic(hWnd) Then
  395.         Caption = sTime
  396.     ElseIf (OldBorder = Border) Or IsZoomed(hWnd) Then
  397.         If ErasingBackgrnd = 0 Then EraseBackGrnd
  398.         Caption = AppName
  399.         ResizeFont
  400.         TimePan.Move 0, 0, ScaleWidth, ScaleHeight
  401.     End If
  402. End Sub
  403. Sub LoadBitMap ()
  404. '*******************************************************
  405. '*                                                     *
  406. '*   Put up a common dialog box to load a bitmap file. *
  407. '*                                                     *
  408. '*******************************************************
  409.     CD.DialogTitle = "Background Bitmap"
  410.     CD.Filter = "BMP files|*.bmp|RLE Files|*.rle|All Files|*.*"
  411.     CD.FilterIndex = 1
  412.     CD.Filename = BackBmp
  413.     CD.Flags = OFN_FILEMUSTEXIST
  414.     CD.Action = DLG_FILE_OPEN
  415.     Screen.MousePointer = 11
  416.     Timer1.Enabled = False
  417.     BackBmp = CD.Filename
  418.     BackMode = BM_BITMAP
  419.     SetBackMode
  420.     Timer1.Enabled = True
  421.     Screen.MousePointer = 0
  422. End Sub
  423. Sub LoadInitFile ()
  424. '*******************************************************
  425. '*                                                     *
  426. '*   Read in the .ini file and set most of the global  *
  427. '*   variables to reflect what you find.               *
  428. '*                                                     *
  429. '*******************************************************
  430.     Dim i As Integer, j As Integer
  431.     Dim f As String, p As String
  432.     Dim R As String * 80
  433.     'On Error Resume Next
  434.     f = InitFile
  435.     p = "Preferences"
  436.     i = GetPrivateProfileString(p, "Position", "", R, 80, f)
  437.     If i >= 7 Then
  438.         j = 1: i = InStr(j, R, " "): If i Then MyRect.Left = Val(Mid$(R, j, i - j))
  439.         j = i + 1: i = InStr(j, R, " "): If i Then MyRect.Right = Val(Mid$(R, j, i - j))
  440.         j = i + 1: i = InStr(j, R, " "): If i Then MyRect.Top = Val(Mid$(R, j, i - j))
  441.         j = i + 1: i = Len(R): If i > j Then MyRect.Bottom = Val(Mid$(R, j, i - j))
  442.         ' the point of the next line is to position the form off the screen until
  443.         ' after it is made visible by the ShowForm procedure
  444.         ' otherwise you get an instant of "garbage" when the form is
  445.         ' first made visible
  446.         Move Screen.Width, Screen.Height
  447.     Else
  448.         ' Arbitrary position defaults
  449.         i = 260 * Tpx
  450.         j = 80 * Tpy
  451.         Move Screen.Width - i, Screen.Height - j, i, j
  452.         GetWindowRect hWnd, MyRect
  453.     End If
  454.     If MyRect.Left > dtw Then
  455.         MyRect.Left = dtw \ 2 - 130
  456.         MyRect.Right = dtw \ 2 + 130
  457.     End If
  458.     If MyRect.Top > dth Then
  459.         MyRect.Top = dth \ 2 - 40
  460.         MyRect.Bottom = dth \ 2 + 40
  461.     End If
  462.     Zoomed = (GetPrivateProfileInt(p, "State", 1, f) = SW_SHOWMAXIMIZED)
  463.     If app.PrevInstance Then
  464.         ' you can have more then one instance, but randomize the placement
  465.         Zoomed = 0
  466.         Randomize
  467.         i = MyRect.Bottom - MyRect.Top
  468.         MyRect.Top = (dth - i) * Rnd
  469.         MyRect.Bottom = MyRect.Top + i
  470.         i = MyRect.Right - MyRect.Left
  471.         MyRect.Left = (dtw - i) * Rnd
  472.         MyRect.Right = MyRect.Left + i
  473.     End If
  474.     TopMost = GetPrivateProfileInt(p, "TopMost", -2, f)
  475.     Border = GetPrivateProfileInt(p, "Border", True, f)
  476.     If Border = False Then
  477.         MsgBlaster1.MsgPassage(2) = 0 'eat WM_NCLBUTTONDBLCLK
  478.     End If
  479.     OldBorder = Border
  480.     Stuck = GetPrivateProfileInt(p, "Stuck", False, f)
  481.     i = GetPrivateProfileString(p, "BackColor", "", R, 80, f)
  482.     If i >= 1 Then TimePan.BackColor = Val(R)
  483.     i = GetPrivateProfileString(p, "ForeColor", "", R, 80, f)
  484.     If i >= 1 Then TimePan.ForeColor = Val(R)
  485.     i = GetPrivateProfileString(p, "FontName", "", R, 80, f)
  486.     If i >= 1 Then TimePan.FontName = Left$(R, i)
  487.     i = GetPrivateProfileString(p, "FontOption", "", R, 80, f)
  488.     If i >= 1 Then
  489.         j = Val(R)
  490.         TimePan.FontBold = j And FO_BD
  491.         TimePan.FontItalic = j And FO_IT
  492.         TimePan.FontStrikethru = j And FO_ST
  493.         TimePan.FontUnderline = j And FO_UL
  494.         TimePan.Font3D = j And FO_3D
  495.     End If
  496.     i = GetPrivateProfileString(p, "FontFact", "", R, 80, f)
  497.     If i >= 1 Then FontFact = Val(R)
  498.     i = GetPrivateProfileString(p, "Font3DColor", "", R, 80, f)
  499.     If i >= 1 Then TimePan.Font3DColor = Val(R)
  500.     TimePan.Font3DSize = GetPrivateProfileInt(p, "Font3DSize", 0, f)
  501.     TimePan.BevelInner = GetPrivateProfileInt(p, "BevelInner", 1, f)
  502.     TimePan.BevelOuter = GetPrivateProfileInt(p, "BevelOuter", 2, f)
  503.     TimePan.BevelInnerShading = GetPrivateProfileInt(p, "BevelInnerShading", 0, f)
  504.     TimePan.BevelOuterShading = GetPrivateProfileInt(p, "BevelOuterShading", 0, f)
  505.     TimePan.BevelInnerWidth = GetPrivateProfileInt(p, "BevelInnerWidth", 1, f)
  506.     TimePan.BevelOuterWidth = GetPrivateProfileInt(p, "BevelOuterWidth", 2, f)
  507.     TimePan.BorderInner = GetPrivateProfileInt(p, "BorderInner", 0, f)
  508.     TimePan.BorderOuter = GetPrivateProfileInt(p, "BorderOuter", 0, f)
  509.     TimePan.BorderInnerWidth = GetPrivateProfileInt(p, "BorderInnerWidth", 0, f)
  510.     TimePan.BorderOuterWidth = GetPrivateProfileInt(p, "BorderOuterWidth", 0, f)
  511.     i = GetPrivateProfileString(p, "BorderInnerColor", "", R, 80, f)
  512.     If i >= 1 Then TimePan.BorderInnerColor = Val(R)
  513.     i = GetPrivateProfileString(p, "BorderOuterColor", "", R, 80, f)
  514.     If i >= 1 Then TimePan.BorderOuterColor = Val(R)
  515.     i = GetPrivateProfileString(p, "DateOption", "", R, 80, f)
  516.     If i >= 1 Then DateOption = Val(R)
  517.     j = 0
  518.     i = GetPrivateProfileString(p, "BackMode", "", R, 80, f)
  519.     If i >= 1 Then
  520.         BackMode = Val(R)
  521.         If BackMode = BM_BITMAP Then BackBmp = Mid$(R, 3, i - 2)
  522.     End If
  523. End Sub
  524. Sub MakeAboutMsg ()
  525. '*******************************************************
  526. '*                                                     *
  527. '*   Make a shameless self promotion for yourself.     *
  528. '*                                                     *
  529. '*******************************************************
  530.     Dim s As String
  531.     s = AppName & " " & Version & nl
  532.     s = s & "by " & Company
  533.     AboutFrm!AboutLab(0) = s
  534.     s = "P.O. Box 243" & nl
  535.     s = s & "Watertown, MA 02272" & nl
  536.     s = s & "CIS: 70402, 3651" & nl
  537.     s = s & "E-Mail: 70402.3651@compuserve.com" & nl
  538.     s = s & CopyRight
  539.     AboutFrm!AboutLab(1) = s
  540.     s = "   theTime is a free program written in "
  541.     s = s & "Visual Basic 3.0 - see technote.txt for the "
  542.     s = s & "techy details and see theTime.wri for "
  543.     s = s & "information about using it.... "
  544.     s = s & "Enjoy!   (Ben Jones)"
  545.     AboutFrm!AboutLab(2) = s
  546. End Sub
  547. Sub MenuStuff (ByVal index As Integer, CheckIt As Integer)
  548. '*******************************************************
  549. '*                                                     *
  550. '*   Manage the checking and unchecking of menu items. *
  551. '*                                                     *
  552. '*******************************************************
  553.     Dim hSubMenu As Integer, checked As Integer
  554.     checked = MF_UNCHECKED
  555.     hSubMenu = GetSubMenu(hMyMenu, 5)
  556.     If CheckIt Then checked = MF_CHECKED
  557.     CheckMenuItem hSubMenu, index, MF_BYPOSITION Or checked
  558.     ' make the changes happen instantly
  559.     Timer1_Timer
  560. End Sub
  561. Sub MsgBlaster1_Message (MsgVal As Integer, wparam As Integer, lParam As Long, ReturnVal As Long)
  562. '*******************************************************
  563. '*                                                     *
  564. '*   Event handler for the ModBlaster control which    *
  565. '*   is a slightly modified version of MsgBlaster that *
  566. '*   is found and documented on the MSDN CD.           *
  567. '*                                                     *
  568. '*******************************************************
  569.     Dim hSubMenu As Integer
  570.     Dim checked As Integer
  571.     Dim lpoint As Long
  572.     Dim R As String * 80
  573.     Select Case MsgVal
  574.         Case WM_NCHITTEST
  575.             ' if there's no title/border and not maximized and not stuck then
  576.             ' and the click is in the client area then change it into a title
  577.             ' bar click so the window can be moved be clicking and dragging it
  578.             If ReturnVal = HTCLIENT And Not Border And IsZoomed(hWnd) = 0 And Not Stuck Then
  579.                 ReturnVal = HTCAPTION
  580.             End If
  581.         
  582.         Case WM_RBUTTONDOWN, WM_NCRBUTTONDOWN
  583.             ' pop up the menu on a right mouse click in the client area
  584.             ' which would be in the non client area (title bar) when
  585.             ' there is no title bar cause of what we did above
  586.             lpoint = lParam
  587.             If MsgVal = WM_RBUTTONDOWN Then
  588.                 ClientToScreenBylong hWnd, lpoint
  589.             ElseIf Border Then
  590.                 GoTo NoPopupMenu ' one goto per program I always say...
  591.             End If
  592.             checked = TrackPopupMenu(hMyMenu, 0, mbLoWord(lpoint), mbHiWord(lpoint), 0, hWnd, 0)
  593. NoPopupMenu:
  594.             ReturnVal = 0 ' this is required when if eat it
  595.         
  596.         Case WM_NCLBUTTONDBLCLK
  597.             ' switch to a title bar/border if there isn't one
  598.             If Not Border Then
  599.                 Border = True
  600.                 ShowTime
  601.                 CheckMenuItem hMyMenu, 1, MF_BYPOSITION Or MF_CHECKED
  602.                 MsgBlaster1.MsgPassage(2) = 1 'let windows post process WM_NCLBUTTONDBLCLK
  603.             End If
  604.             ReturnVal = 0 ' this is required if we eat it
  605.         
  606.         Case WM_LBUTTONDBLCLK
  607.             ' get rid of the title bar/border if there is one
  608.             Border = Not Border
  609.             ShowTime
  610.             CheckMenuItem hMyMenu, 1, MF_BYPOSITION Or MF_UNCHECKED
  611.             MsgBlaster1.MsgPassage(2) = 0 'eat WM_NCLBUTTONDBLCLK
  612.             ReturnVal = 0 ' this is required if we eat it
  613.         
  614.         Case WM_MOUSEACTIVATE
  615.             ' if stuck then avoid getting focus
  616.             If Stuck Then
  617.                 ReturnVal = MA_NOACTIVATE
  618.             Else
  619.                 ReturnVal = 0 ' this is required when if eat it
  620.             End If
  621.         
  622.         Case WM_MOVE
  623.             If ErasingBackgrnd = 0 Then EraseBackGrnd
  624.         
  625.         Case WM_ERASEBKGND
  626.             EraseBackGrnd
  627.             '  suppress normal erase backgound proccesing
  628.             ReturnVal = 1
  629.         
  630.         Case WM_DROPFILES
  631.             If DragQueryFile(wparam, 0, R, 80) Then
  632.                 'Debug.Print "dropfile, begin"
  633.                 Timer1.Enabled = False
  634.                 BackBmp = R
  635.                 BackMode = BM_BITMAP
  636.                 SetBackMode
  637.                 CheckBackItem
  638.                 Timer1.Enabled = True
  639.             End If
  640.             DragFinish wparam
  641.             Refresh
  642.             ReturnVal = 0
  643.             'Debug.Print "dropfile, end"
  644.         
  645.         Case WM_SYSCOMMAND, WM_COMMAND
  646.             ReturnVal = False ' this prevents post-processing by the modblaster control
  647.             checked = MF_CHECKED
  648.             ' cancel fetching the background
  649.             Select Case wparam
  650.                 Case 100 ' Top most
  651.                     If TopMost = HWND_NOTOPMOST Then
  652.                         TopMost = HWND_TOPMOST
  653.                     Else
  654.                         checked = MF_UNCHECKED
  655.                         TopMost = HWND_NOTOPMOST
  656.                     End If
  657.                     CheckMenuItem hMyMenu, 0, MF_BYPOSITION Or checked
  658.                     ShowTime
  659.                 Case 200 ' Title Bar
  660.                     Border = Not Border
  661.                     If Not Border Then
  662.                         checked = MF_UNCHECKED
  663.                         MsgBlaster1.MsgPassage(2) = 0 'eat WM_NCLBUTTONDBLCLK
  664.                     End If
  665.                     CheckMenuItem hMyMenu, 1, MF_BYPOSITION Or checked
  666.                     ShowTime
  667.                 Case 700 ' Stuck
  668.                     Stuck = Not Stuck
  669.                     If Not Stuck Then
  670.                         checked = MF_UNCHECKED
  671.                         SetFocus
  672.                     End If
  673.                     CheckMenuItem hMyMenu, 2, MF_BYPOSITION Or checked
  674.                 Case 310
  675.                     BackMode = BM_SOLID
  676.                     SetBackMode
  677.                     CheckBackItem
  678.                 Case 320
  679.                     LoadBitMap
  680.                     CheckBackItem
  681.                 Case 330
  682.                     BackMode = BM_TRANSPARENT
  683.                     SetBackMode
  684.                     CheckBackItem
  685.                 Case 340 ' Background Color
  686.                     CD.Flags = CC_RGBINIT
  687.                     CD.Color = TimePan.BackColor
  688.                     CD.Action = DLG_COLOR
  689.                     TimePan.BackColor = CD.Color
  690.                 Case 410 To 414 ' Font 3d Options
  691.                     hSubMenu = GetSubMenu(hMyMenu, 5)
  692.                     hSubMenu = GetSubMenu(hSubMenu, 0)
  693.                     CheckMenuItem hSubMenu, TimePan.Font3D, MF_BYPOSITION Or MF_UNCHECKED
  694.                     CheckMenuItem hSubMenu, wparam - 410, MF_BYPOSITION Or MF_CHECKED
  695.                     TimePan.Font3D = wparam - 410
  696.                 Case 415 To 419 ' Font 3d Size
  697.                     checked = TimePan.Font3DSize + wparam - 417
  698.                     If checked > 0 And checked <= 30 Then
  699.                         TimePan.Font3DSize = checked
  700.                     End If
  701.                 Case 420 ' thetime fonts
  702.                     CD.Color = TimePan.ForeColor
  703.                     CD.FontBold = TimePan.FontBold
  704.                     CD.FontItalic = TimePan.FontItalic
  705.                     CD.FontName = TimePan.FontName
  706.                     CD.FontSize = TimePan.FontSize
  707.                     CD.FontStrikeThru = TimePan.FontStrikethru
  708.                     CD.FontUnderLine = TimePan.FontUnderline
  709.                     CD.Flags = CF_BOTH Or CF_EFFECTS
  710.                     CD.Action = DLG_FONT
  711.                     TimePan.ForeColor = CD.Color
  712.                     TimePan.FontBold = CD.FontBold
  713.                     TimePan.FontItalic = CD.FontItalic
  714.                     TimePan.FontName = CD.FontName
  715.                     FontFact = FontFact * CD.FontSize / TimePan.FontSize
  716.                     TimePan.FontSize = CD.FontSize
  717.                     TimePan.FontStrikethru = CD.FontStrikeThru
  718.                     TimePan.FontUnderline = CD.FontUnderLine
  719.                 Case 425 ' Font 3D Color
  720.                     CD.Flags = CC_RGBINIT
  721.                     CD.Color = TimePan.Font3DColor
  722.                     CD.Action = DLG_COLOR
  723.                     TimePan.Font3DColor = CD.Color
  724.                 Case 430' Military Time
  725.                     DateOption = DateOption Xor DO_MT
  726.                     MenuStuff 3, DateOption And DO_MT
  727.                 Case 440' Full Day
  728.                     DateOption = DateOption Xor DO_DN
  729.                     MenuStuff 4, DateOption And DO_DN
  730.                 Case 450' Full Month
  731.                     DateOption = DateOption Xor DO_FM
  732.                     MenuStuff 5, DateOption And DO_FM
  733.                 Case 460' Full Year
  734.                     DateOption = DateOption Xor DO_FY
  735.                     MenuStuff 6, DateOption And DO_FY
  736.                 Case 465' Two Lines
  737.                     DateOption = DateOption Xor DO_1L
  738.                     MenuStuff 7, DateOption And DO_1L
  739.                 Case 470 To 474' Date Options
  740.                     hSubMenu = GetSubMenu(hMyMenu, 5)
  741.                     hSubMenu = GetSubMenu(hSubMenu, 9)
  742.                     CheckMenuItem hSubMenu, DateOption And DO_DF, MF_BYPOSITION Or MF_UNCHECKED
  743.                     CheckMenuItem hSubMenu, wparam - 470, MF_BYPOSITION Or MF_CHECKED
  744.                     DateOption = (DateOption And (Not DO_DF)) Or wparam - 470
  745.                     Timer1_Timer
  746.                 Case 500' Bevels
  747.                     ShowBevelOptFrm
  748.                 Case 600' About
  749.                     ShowAboutFrm
  750.                 Case 900' Exit - but don't end in the middle of this message
  751.                     SaveInitFile
  752.                     If (GetAsyncKeyState(VK_SHIFT) And &H8000) = 0 Then
  753.                         ' shift key not pressed, go ahead and exit
  754.                         ' first un-subclass everybody
  755.                         MsgBlaster1.hWndTarget = 0
  756.                         MsgBlaster1.hWndTarget = 0
  757.                         FreeLibrary (GetModuleHandle("modblast.vbx"))
  758.                         End
  759.                     End If
  760.                 Case SC_CLOSE ' handle this so we can un-subclass and free the library
  761.                     SaveInitFile
  762.                     ReturnVal = True ' enable post-processing
  763.                 Case Else
  764.                     ReturnVal = True ' enable post-processing
  765.             End Select
  766.     End Select
  767. End Sub
  768. Sub ResizeFont ()
  769. '*******************************************************
  770. '*                                                     *
  771. '*   Attempt to resize the font proportionately to the *
  772. '*   size of theTime's panel.  FontFact keeps track of *
  773. '*   the size of the font relative to the form.  It's  *
  774. '*   a kludge but it seems to work.                    *
  775. '*                                                     *
  776. '*******************************************************
  777.     Dim Fsw As Single, Fsh As Single
  778.     Dim lines As Single, x As Single
  779.     Dim aRect As RECT
  780.     Dim i As Integer, j As Integer
  781.     If InStr(sDate, nl) Then
  782.         lines = 2.5
  783.         j = Len(sDate) - 1
  784.         If j < Len(sTime) Then
  785.             j = Len(sTime)
  786.         End If
  787.     Else
  788.         lines = 1.5
  789.         j = Len(sDate & sTime)
  790.         If j = 0 Then Exit Sub
  791.     End If
  792.     If TimePan.BorderOuter Then i = i + TimePan.BorderOuterWidth
  793.     If TimePan.BevelOuter Then i = i + TimePan.BevelInnerWidth
  794.     If TimePan.BorderInner Then i = i + TimePan.BorderInnerWidth
  795.     If TimePan.BevelInner Then i = i + TimePan.BevelInnerWidth
  796.     GetClientRect hWnd, aRect
  797.     InflateRect aRect, -i, -i
  798.     Fsw = (aRect.Right - aRect.Left) * Tpx * FontFact / (10 * j) ' how big can the fonts be according to width
  799.     Fsh = (aRect.Bottom - aRect.Top) * Tpy * FontFact / (20 * lines)' ... according to height
  800.     If Fsw < Fsh Then
  801.         x = Fsw
  802.     Else
  803.         x = Fsh
  804.     End If
  805.     If x < 8# Then x = 8#
  806.     TimePan.FontSize = x
  807. End Sub
  808. Sub SaveInitFile ()
  809. '*******************************************************
  810. '*                                                     *
  811. '*   Write the ini file.                               *
  812. '*                                                     *
  813. '*******************************************************
  814.     Dim i As Integer
  815.     Dim f As String, p As String, s As String
  816.     Dim MyPlace As WINDOWPLACEMENT
  817.     If app.PrevInstance Then
  818.         Exit Sub
  819.     End If
  820.     Screen.MousePointer = 11
  821.     f = InitFile
  822.     p = "Preferences"
  823.     MyPlace.Length = 22
  824.     GetWindowPlacement hWnd, MyPlace
  825.     CopyRect MyRect, MyPlace.rcNormalPosition
  826.     s = Str$(MyRect.Left) & Str$(MyRect.Right) & Str$(MyRect.Top) & Str$(MyRect.Bottom)
  827.     i = WritePrivateProfileString(p, "Position", s, f)
  828.     i = WritePrivateProfileString(p, "State", Str$(MyPlace.ShowCmd), f)
  829.     i = WritePrivateProfileString(p, "TopMost", Str$(TopMost), f)
  830.     i = WritePrivateProfileString(p, "Border", Str$(Border), f)
  831.     i = WritePrivateProfileString(p, "Stuck", Str$(Stuck), f)
  832.     i = WritePrivateProfileString(p, "BackColor", "&h" & Hex$(TimePan.BackColor) & "&", f)
  833.     i = WritePrivateProfileString(p, "ForeColor", "&h" & Hex$(TimePan.ForeColor) & "&", f)
  834.     i = WritePrivateProfileString(p, "FontName", TimePan.FontName, f)
  835.     i = TimePan.Font3D
  836.     If TimePan.FontBold Then i = i Or FO_BD
  837.     If TimePan.FontItalic Then i = i Or FO_IT
  838.     If TimePan.FontStrikethru Then i = i Or FO_ST
  839.     If TimePan.FontUnderline Then i = i Or FO_UL
  840.     i = WritePrivateProfileString(p, "FontOption", "&h" & Hex$(i), f)
  841.     i = WritePrivateProfileString(p, "FontFact", Str$(FontFact), f)
  842.     i = WritePrivateProfileString(p, "Font3DColor", "&h" & Hex$(TimePan.Font3DColor) & "&", f)
  843.     i = WritePrivateProfileString(p, "Font3DSize", Str$(TimePan.Font3DSize), f)
  844.     i = WritePrivateProfileString(p, "BevelInner", Str$(TimePan.BevelInner), f)
  845.     i = WritePrivateProfileString(p, "BevelOuter", Str$(TimePan.BevelOuter), f)
  846.     i = WritePrivateProfileString(p, "BevelInnerShading", Str$(TimePan.BevelInnerShading), f)
  847.     i = WritePrivateProfileString(p, "BevelOuterShading", Str$(TimePan.BevelOuterShading), f)
  848.     i = WritePrivateProfileString(p, "BevelInnerWidth", Str$(TimePan.BevelInnerWidth), f)
  849.     i = WritePrivateProfileString(p, "BevelOuterWidth", Str$(TimePan.BevelOuterWidth), f)
  850.     i = WritePrivateProfileString(p, "BorderInner", Str$(TimePan.BorderInner), f)
  851.     i = WritePrivateProfileString(p, "BorderOuter", Str$(TimePan.BorderOuter), f)
  852.     i = WritePrivateProfileString(p, "BorderInnerWidth", Str$(TimePan.BorderInnerWidth), f)
  853.     i = WritePrivateProfileString(p, "BorderOuterWidth", Str$(TimePan.BorderOuterWidth), f)
  854.     i = WritePrivateProfileString(p, "BorderInnerColor", "&h" & Hex$(TimePan.BorderInnerColor) & "&", f)
  855.     i = WritePrivateProfileString(p, "BorderOuterColor", "&h" & Hex$(TimePan.BorderOuterColor) & "&", f)
  856.     i = WritePrivateProfileString(p, "DateOption", "&h" & Hex$(DateOption), f)
  857.     s = Str$(BackMode) & " " & BackBmp
  858.     i = WritePrivateProfileString(p, "Backmode", s, f)
  859.     Screen.MousePointer = 0
  860. End Sub
  861. Sub SetBackMode ()
  862. '*******************************************************
  863. '*                                                     *
  864. '*   Set the background modeont proportionately to the *
  865. '*   size of theTime's panel.  FontFact keeps track of *
  866. '*   the size of the font relative to the form.  It's  *
  867. '*   a kludge but it seems to work.                    *
  868. '*                                                     *
  869. '*******************************************************
  870.     On Error Resume Next
  871.     TimePan.BackStyle = 1
  872.     If BackMode = BM_SOLID Then
  873.         TimePan.Picture = LoadPicture("")
  874.         BackBmp = ""
  875.     ElseIf BackMode = BM_BITMAP Then ' loading a bitmap
  876.         TimePan.Picture = LoadPicture(BackBmp)
  877.         If Err <> 0 Then
  878.             MsgBox "Error loading " & BackBmp & nl & "Invalid bitmap file format!", 48
  879.             ' no bitmap loaded
  880.             BackMode = BM_SOLID
  881.             BackBmp = ""
  882.         End If
  883.     Else
  884.         TimePan.BackStyle = 0
  885.         ' the next two lines do about the same thing. One advantage to using
  886.         ' InvalidateRectbynum is that erasing the background can be turned off
  887.         'InvalidateRectbynum hwnd, 0, True
  888.         Refresh
  889.     End If
  890. End Sub
  891. Sub ShowAboutFrm ()
  892. '*******************************************************
  893. '*                                                     *
  894. '*   Show a shameless self promotion.                  *
  895. '*                                                     *
  896. '*******************************************************
  897.     Dim i As Integer
  898.     MakeAboutMsg
  899.     AdjustForm AboutFrm
  900.     AboutFrm.Caption = "About " & AppName
  901.     AboutFrm!AboutPan.Icon = Icon
  902.     ' this form might need to be set topmost
  903.     SetWindowPos AboutFrm.hWnd, TopMost, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE
  904.     AboutFrm.Show 1
  905.     Unload AboutFrm
  906. End Sub
  907. Sub ShowBevelOptFrm ()
  908. '*******************************************************
  909. '*                                                     *
  910. '*   Now for the really interesting stuff.  Show a     *
  911. '*   dialog box that is almost entirely created out of *
  912. '*   PZLabels.  PZLabels are part of Pizazz.vbx, an    *
  913. '*   inexpensize VBX that can be purchased through     *
  914. '*   Compuserve (#6551).   Remarkably enough, it is    *
  915. '*   possible to make tabs, 3D options, and 3D spin    *
  916. '*   buttons with a little code and Pizazz!.           *
  917. '*                                                     *
  918. '*******************************************************
  919.     Dim f As Form, T As PZLabel
  920.     ReDim opt(1) As Integer
  921.     Dim i As Integer
  922.     ' use object variables to make my typing easier!
  923.     Set f = BevelOptFrm
  924.     Set T = TimePan
  925.     AdjustForm f
  926.     ' pass properties using tags
  927.     f!TabPan.Tag = "0" ' set the "up" tab
  928.     f!Tabs(0).Tag = Str$(T.BevelOuter)
  929.     f!Tabs(1).Tag = Str$(T.BevelInner)
  930.     f!Tabs(2).Tag = Str$(T.BorderOuter)
  931.     f!Tabs(3).Tag = Str$(T.BorderInner)
  932.     f!WidthLab(0) = Str$(T.BevelOuterWidth)
  933.     f!WidthLab(1) = Str$(T.BevelInnerWidth)
  934.     f!WidthLab(2) = Str$(T.BorderOuterWidth)
  935.     f!WidthLab(3) = Str$(T.BorderInnerWidth)
  936.     ' setting the bevel shade options is confusing because
  937.     ' the "white light" option reverses its value depending
  938.     ' on the "black shade" option
  939.     opt(0) = T.BevelOuterShading
  940.     opt(1) = T.BevelInnerShading
  941.     For i = 0 To 1
  942.         ' there are four color option buttons, two for each property
  943.         f!ColorOpt(i * 2).Tag = Str$((opt(i) < 2 Xor opt(i)) And 1)
  944.         f!ColorOpt(i * 2 + 1).Tag = Str$(opt(i) And 2)
  945.     Next
  946.     f!ColorOpt(4).Tag = Str$(T.BorderOuterColor)
  947.     f!ColorOpt(6).Tag = Str$(T.BorderInnerColor)
  948.     ' might need to be set topmost
  949.     SetWindowPos BevelOptFrm.hWnd, TopMost, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE
  950.     f.Show 1
  951.     If Trim$(f.Tag) = "1" Then
  952.         ' OK was pressed
  953.         T.BevelOuter = Val(f!Tabs(0).Tag)
  954.         T.BevelInner = Val(f!Tabs(1).Tag)
  955.         T.BorderOuter = Val(f!Tabs(2).Tag)
  956.         T.BorderInner = Val(f!Tabs(3).Tag)
  957.         T.BevelOuterWidth = Val(f!WidthLab(0))
  958.         T.BevelInnerWidth = Val(f!WidthLab(1))
  959.         T.BorderOuterWidth = Val(f!WidthLab(2))
  960.         T.BorderInnerWidth = Val(f!WidthLab(3))
  961.         For i = 0 To 1
  962.             opt(i) = Val(f!ColorOpt(i * 2 + 1).Tag)
  963.             opt(i) = opt(i) + Val(f!ColorOpt(i * 2).Tag) Xor (opt(i) < 2) And 1
  964.         Next
  965.         T.BevelOuterShading = opt(0)
  966.         T.BevelInnerShading = opt(1)
  967.         T.BorderOuterColor = Val(f!ColorOpt(4).Tag)
  968.         T.BorderInnerColor = Val(f!ColorOpt(6).Tag)
  969.         ResizeFont
  970.     End If
  971.     Unload BevelOptFrm
  972. End Sub
  973. Sub ShowForm ()
  974. '*******************************************************
  975. '*                                                     *
  976. '*   Show theTime's form.  Can't just do a show method *
  977. '*   because the form's title and borders may or may   *
  978. '*   not be present and the form may have the TopMost  *
  979. '*   position and good old VB doesn't support setting  *
  980. '*   these things at run time.                         *
  981. '*                                                     *
  982. '*******************************************************
  983.     Dim x As Integer, y As Integer
  984.     Dim w As Integer, h As Integer
  985.     Dim i As Integer
  986.     Dim Clrect As RECT
  987.     Dim MyPlace As WINDOWPLACEMENT
  988.     Dim l As Long
  989.     If Border Then
  990.         l = WS_OVERLAPPEDWINDOW Or WS_VISIBLE
  991.     Else
  992.         l = WS_VISIBLE
  993.     End If
  994.     If Zoomed Then
  995.         l = l Or WS_MAXIMIZE
  996.     End If
  997.     l = SetWindowLong(hWnd, GWL_STYLE, l)
  998.     If Zoomed = 0 Then
  999.         x = MyRect.Left
  1000.         y = MyRect.Top
  1001.         w = MyRect.Right - x
  1002.         h = MyRect.Bottom - y
  1003.         If x > dtw - BorderSize Then
  1004.             x = dtw - w
  1005.         End If
  1006.         If y > dth - BorderSize Then
  1007.             y = dth - h
  1008.         End If
  1009.     Else
  1010.         If Border Then i = BorderSize
  1011.         x = -i
  1012.         y = -i
  1013.         w = dtw + 2 * i
  1014.         h = dth + 2 * i
  1015.     End If
  1016.     ' the next line fires the move and form resize event and makes
  1017.     ' the form visible
  1018.     ' (note this is only way to set topmost)
  1019.     SetWindowPos hWnd, TopMost, x, y, w, h, SWP_NOACTIVATE
  1020.     If Not Stuck Then SetFocus
  1021.     If Zoomed Then
  1022.         MyPlace.Length = 22
  1023.         GetWindowPlacement hWnd, MyPlace
  1024.         CopyRect MyPlace.rcNormalPosition, MyRect
  1025.         SetWindowPlacement hWnd, MyPlace
  1026.     End If
  1027.     TimePan.Visible = True
  1028. End Sub
  1029. Sub ShowTime ()
  1030. '*******************************************************
  1031. '*                                                     *
  1032. '*   Set the border and title or lack thereof window   *
  1033. '*   style and the topmost position while you're at    *
  1034. '*   it.                                               *
  1035. '*                                                     *
  1036. '*******************************************************
  1037.     Dim l As Long
  1038.     Dim x As Integer, y As Integer
  1039.     Dim w As Integer, h As Integer
  1040.     Dim i As Integer
  1041.     Dim flag As Long
  1042.     Dim Clrect As RECT
  1043.     If Border <> OldBorder Then
  1044.         GetWindowRect hWnd, MyRect
  1045.         GetClientRect hWnd, Clrect
  1046.         Zoomed = IsZoomed(hWnd)
  1047.         flag = WS_VISIBLE ' no border, no caption, no nothin
  1048.         If Zoomed = 0 Then
  1049.             If Border Then
  1050.                 x = MyRect.Left - BorderSize
  1051.                 y = MyRect.Top - TitleSize - BorderSize
  1052.                 w = MyRect.Right - MyRect.Left + 2 * BorderSize
  1053.                 h = MyRect.Bottom - MyRect.Top + TitleSize + 2 * BorderSize
  1054.             Else
  1055.                 x = MyRect.Left + BorderSize
  1056.                 y = MyRect.Top + TitleSize + BorderSize
  1057.                 w = Clrect.Right - Clrect.Left
  1058.                 h = Clrect.Bottom - Clrect.Top
  1059.             End If
  1060.         Else
  1061.             If Border Then i = BorderSize
  1062.             x = -i
  1063.             y = -i
  1064.             w = dtw + 2 * i
  1065.             h = dth + 2 * i
  1066.         End If
  1067.         If Border Then
  1068.             flag = flag Or WS_OVERLAPPEDWINDOW Or WS_VISIBLE ' back to normal
  1069.         End If
  1070.         If Zoomed Then
  1071.             flag = flag Or WS_MAXIMIZE
  1072.         End If
  1073.         l = SetWindowLong(hWnd, GWL_STYLE, flag)
  1074.         SetWindowPos hWnd, TopMost, x, y, w, h, SWP_NOACTIVATE
  1075.         OldBorder = Border
  1076.     Else
  1077.         SetWindowPos hWnd, TopMost, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE
  1078.     End If
  1079. End Sub
  1080. Sub Timer1_Timer ()
  1081. '*******************************************************
  1082. '*                                                     *
  1083. '*   Event handler for the timer.  Update the time.    *
  1084. '*                                                     *
  1085. '*******************************************************
  1086.     Dim mm As String, yy As String
  1087.     sTime = "h:mm"
  1088.     If (DateOption And DO_MT) = 0 Then sTime = sTime & " A/P"
  1089.     sDate = ""
  1090.     If DateOption And DO_DN Then sDate = "dddd "
  1091.     mm = "mmm"
  1092.     If DateOption And DO_FM Then mm = "mmmm"
  1093.     yy = "yy  "
  1094.     If DateOption And DO_FY Then yy = "yyyy  "
  1095.     Select Case DateOption And DO_DF
  1096.         Case 0 'no date
  1097.         Case 1 'd/m/y
  1098.             sDate = sDate & "m/d/" & yy
  1099.         Case 2 'm-d-y
  1100.             sDate = sDate & "dd-" & mm & "-" & yy
  1101.         Case 3 'm d, y
  1102.             sDate = sDate & mm & " d, " & yy
  1103.         Case 4 'm d
  1104.             sDate = sDate & mm & " d  "
  1105.     End Select
  1106.     If sDate <> "" Then
  1107.         sDate = Format$(Now, sDate)
  1108.     End If
  1109.     If Command$ <> "" Then
  1110.         sDate = Command$ & " " & sDate
  1111.     End If
  1112.     If sDate <> "" And ((DateOption And DO_1L) = 0) Then
  1113.         sDate = RTrim$(sDate) & nl ' two lines
  1114.     End If
  1115.     sTime = Format$(Now, sTime)
  1116.     If IsIconic(hWnd) Then
  1117.         If sTime <> Caption Then Caption = sTime
  1118.     ElseIf sDate & sTime <> TimePan.Caption Then
  1119.         ResizeFont
  1120.         TimePan.Caption = sDate & sTime
  1121.         EraseBackGrnd
  1122.     End If
  1123.     If ErasingBackgrnd = 1 Then EraseBackGrnd
  1124. End Sub
  1125.