![]()
=======================vbclock.frm VERSION 5.00 Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx" Begin VB.Form frmVBClock BackColor = &H00C0C0C0& BorderStyle = 3 'Fixed Dialog Caption = "VBClock" ClientHeight = 4956 ClientLeft = 2376 ClientTop = 2316 ClientWidth = 5412 BeginProperty Font Name = "MS Sans Serif" Size = 7.8 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Icon = "VBClock.frx":0000 LinkTopic = "Form1" MaxButton = 0 'False PaletteMode = 1 'UseZOrder ScaleHeight = 4956 ScaleWidth = 5412 ShowInTaskbar = 0 'False Begin VB.PictureBox picBackGround AutoRedraw = -1 'True AutoSize = -1 'True Height = 3624 Left = 780 Picture = "VBClock.frx":0442 ScaleHeight = 3576 ScaleWidth = 3564 TabIndex = 0 Top = 300 Width = 3612 End Begin VB.Timer tmrClock Interval = 100 Left = 180 Top = 660 End Begin MSComDlg.CommonDialog cdlOne Left = 120 Top = 1560 _ExtentX = 847 _ExtentY = 847 _Version = 393216 End Begin VB.Menu mnuFile Caption = "&File" Begin VB.Menu mnuNew Caption = "&New" Enabled = 0 'False End Begin VB.Menu mnuOpen Caption = "&Open..." Enabled = 0 'False End Begin VB.Menu mnuSave Caption = "&Save" Enabled = 0 'False End Begin VB.Menu mnuSaveAs Caption = "Save &As..." Enabled = 0 'False End Begin VB.Menu mnuFileDash1 Caption = "-" End Begin VB.Menu mnuExit Caption = "E&xit" End End Begin VB.Menu mnuOption Caption = "&Options" Begin VB.Menu mnuSetTime Caption = "&Set Time..." End Begin VB.Menu mnuHandColors Caption = "&Hand Colors..." End End Begin VB.Menu mnuHelp Caption = "&Help" Begin VB.Menu mnuContents Caption = "&Contents" HelpContextID = 101 End Begin VB.Menu mnuSearch Caption = "&Search For Help On..." HelpContextID = 102 End Begin VB.Menu mnuHelpDash1 Caption = "-" End Begin VB.Menu mnuAbout Caption = "&About..." End End End Attribute VB_Name = "frmVBClock" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim Hnum As Integer Dim Mnum As Integer Dim Snum As Integer Dim Hcolor As Long Dim Mcolor As Long Dim Scolor As Long Dim Hlen As Single Dim Mlen As Single Dim Slen As Single Dim Appname$, Section$, Key$, Setting$ Public HourHandColor As Integer Public MinuteHandColor As Integer Public SecondHandColor As Integer Const Pi = 3.14159265358979 Const TwoPi = Pi + Pi Const HalfPi = Pi / 2 Private Sub Form_Load() 'Fill form exactly with background image picBackGround.Move 0, 0 Width = picBackGround.Width + (Width - ScaleWidth) Height = picBackGround.Height + (Height - ScaleHeight) 'Change the scaling of the clock face picBackGround.Scale (-2, -2)-(2, 2) 'Center form Left = (Screen.Width - Width) \ 2 Top = (Screen.Height - Height) \ 2 'Set width of hands in pixels picBackGround.DrawWidth = 5 'Set length of hands Hlen = 0.8 Mlen = 1.5 Slen = 1 'Set colors of hands from Registy settings Appname$ = "VBClock" Section$ = "Hands" Key$ = "Hcolor" Setting$ = GetSetting(Appname$, Section$, Key$) HourHandColor = Val(Setting$) Key$ = "Mcolor" Setting$ = GetSetting(Appname$, Section$, Key$) MinuteHandColor = Val(Setting$) Key$ = "Scolor" Setting$ = GetSetting(Appname$, Section$, Key$) SecondHandColor = Val(Setting$) End Sub Private Sub Form_Unload(Cancel As Integer) 'Save current hand colors Key$ = "Hcolor" Setting$ = Str$(HourHandColor) SaveSetting Appname$, Section$, Key$, Setting$ Key$ = "Mcolor" Setting$ = Str$(MinuteHandColor) SaveSetting Appname$, Section$, Key$, Setting$ Key$ = "Scolor" Setting$ = Str$(SecondHandColor) SaveSetting Appname$, Section$, Key$, Setting$ End Sub Private Sub mnuAbout_Click() frmAbout2.Display End Sub Private Sub mnuExit_Click() Unload Me End Sub Private Sub mnuContents_Click() ''cdlOne.HelpFile = App.Path & "\..\..\Help\Mvbdw.hlp" cdlOne.HelpCommand = cdlHelpContents cdlOne.ShowHelp End Sub Private Sub mnuHandColors_Click() 'Show form for selecting hand colors frmVBClock2.Show vbModal End Sub Private Sub mnuSearch_Click() ''cdlOne.HelpFile = App.Path & "\..\..\Help\Mvbdw.hlp" cdlOne.HelpCommand = cdlHelpPartialKey cdlOne.ShowHelp End Sub Private Sub tmrClock_Timer() Dim Hang As Double Dim Mang As Double Dim Sang As Double Dim Hx As Double Dim Hy As Double Dim Mx As Double Dim My As Double Dim Sx As Double Dim Sy As Double 'Keep track of current second Static LastSecond 'Check to see if new second If Second(Now) = LastSecond Then Exit Sub Else LastSecond = Second(Now) End If 'Update time variables Hnum = Hour(Now) Mnum = Minute(Now) Snum = Second(Now) 'Calculate hand angles Hang = TwoPi * (Hnum + Mnum / 60) / 12 - HalfPi Mang = TwoPi * (Mnum + Snum / 60) / 60 - HalfPi Sang = TwoPi * Snum / 60 - HalfPi 'Calculate endpoints for each hand Hx = Hlen * Cos(Hang) Hy = Hlen * Sin(Hang) Mx = Mlen * Cos(Mang) My = Mlen * Sin(Mang) Sx = Slen * Cos(Sang) Sy = Slen * Sin(Sang) 'Restore background image picBackGround.Cls 'Draw new hands picBackGround.Line (0, 0)-(Mx, My), QBColor(MinuteHandColor) picBackGround.Line (0, 0)-(Hx, Hy), QBColor(HourHandColor) picBackGround.Line (0, 0)-(Sx, Sy), QBColor(SecondHandColor) End Sub Private Sub mnuSetTime_Click() Dim Prompt$, Title$, Default$ Dim StartTime$, Tim$, Msg$ 'Ask user for new time Prompt$ = "Enter the time, using the format 00:00:00" Title$ = "VBClock" Default$ = Time$ StartTime$ = Default$ Tim$ = InputBox$(Prompt$, Title$, Default$) 'Check if user clicked on Cancel 'or clicked on OK with no change to time If Tim$ = "" Or Tim$ = StartTime$ Then Exit Sub End If 'Set new time On Error GoTo ErrorTrap Time$ = Tim$ Exit Sub ErrorTrap: Msg$ = "The time you entered is invalid... " + Tim$ MsgBox Msg$, 48, "VBClock" Resume Next End Sub =======================vbclock.vbp Type=Exe Form=VBClock.frm Form=About2.frm Form=VBClock2.frm Object={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0; comdlg32.ocx IconForm="frmVBClock" Startup="frmVBClock" HelpFile="" Title="Visual Basic 4.0 Developer's Workshop" ExeName32="VBClock.Exe" Command32="" Name="Project1" HelpContextID="0" CompatibleMode="0" MajorVer=1 MinorVer=0 RevisionVer=0 AutoIncrementVer=0 ServerSupportFiles=0 VersionComments="Windows 95 32-bit Visual Basic 4.0 " VersionCompanyName="Craig Software" VersionFileDescription="Example file description" VersionLegalCopyright="Copyright © 1996 John Clark Craig: Author" VersionLegalTrademarks="Example Trademark" VersionProductName="VBClock" CompilationType=0 OptimizationType=0 FavorPentiumPro(tm)=0 CodeViewDebugInfo=0 NoAliasing=0 BoundsCheck=0 OverflowCheck=0 FlPointCheck=0 FDIVCheck=0 UnroundedFP=0 StartMode=0 Unattended=0 ThreadPerObject=0 MaxNumberOfThreads=1