Time Viewer Tutorial

Status
Not open for further replies.

victor12345

New Member
Messages
42
Reaction score
0
Points
0
How to make a time viewer in the icon tray:
I just designed it from scratch. I also know that I have alot of stuff I don\'t need!
1. Create The Design of the forms
1. Form1 (Only form to design)
You need the following objects
Form Settings
1. FormBorderStyle => None
Just Scatter the labels around, it doesn\'t matter the slightest!
1. Label1 - No purpose at the moment
2. Label2 - No purpose at the moment
3. Label3 ---=> Text => 00:00:00
4. Label4 -/
5. Label5 ---=> Text => Dec 1, 10001
6. Label6 -/
These have no location, so who cares about the location?
7. Timer1 => Interval => 1 | Enabled =>1
8. NotifyIcon1 => Visible => True | Icon MUST be set to anything, but it just has to be set to something!
For those lazy people, I am using Microsoft Visual Studio 2008 Beta 2, free for about 300 days. This is the content of Form1.Designer.vb :
==================================Start Code==================================
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
\'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
\'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
\'NOTE: The following procedure is required by the Windows Form Designer
\'It can be modified using the Windows Form Designer.
\'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.Label6 = New System.Windows.Forms.Label
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.NotifyIcon1 = New System.Windows.Forms.NotifyIcon(Me.components)
Me.SuspendLayout()
\'
\'Label1
\'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(1, -2)
Me.Label1.Margin = New System.Windows.Forms.Padding(6, 0, 6, 0)
Me.Label1.Name = \"Label1\"
Me.Label1.Size = New System.Drawing.Size(238, 36)
Me.Label1.TabIndex = 0
Me.Label1.Text = \"Calgary (GMT-7)\"
\'
\'Label2
\'
Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font(\"Microsoft Sans Serif\", 15.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(1, 34)
Me.Label2.Margin = New System.Windows.Forms.Padding(6, 0, 6, 0)
Me.Label2.Name = \"Label2\"
Me.Label2.Size = New System.Drawing.Size(234, 29)
Me.Label2.TabIndex = 1
Me.Label2.Text = \"Shenzhen (GMT+8)\"
\'
\'Label3
\'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(244, -2)
Me.Label3.Name = \"Label3\"
Me.Label3.Size = New System.Drawing.Size(133, 36)
Me.Label3.TabIndex = 2
Me.Label3.Text = \"00:00:00\"
\'
\'Label4
\'
Me.Label4.AutoSize = True
Me.Label4.Location = New System.Drawing.Point(244, 34)
Me.Label4.Name = \"Label4\"
Me.Label4.Size = New System.Drawing.Size(133, 36)
Me.Label4.TabIndex = 3
Me.Label4.Text = \"00:00:00\"
\'
\'Label5
\'
Me.Label5.AutoSize = True
Me.Label5.Location = New System.Drawing.Point(383, -2)
Me.Label5.Name = \"Label5\"
Me.Label5.Size = New System.Drawing.Size(193, 36)
Me.Label5.TabIndex = 4
Me.Label5.Text = \"Dec 1, 10001\"
\'
\'//------------------------------------------------------//\'
It\'s So long! See Next Post!
 

victor12345

New Member
Messages
42
Reaction score
0
Points
0
Here\'s The Continued Post
\'//-------------------------------------------//\'
\'Label6
\'
Me.Label6.AutoSize = True
Me.Label6.Location = New System.Drawing.Point(383, 34)
Me.Label6.Name = \"Label6\"
Me.Label6.Size = New System.Drawing.Size(193, 36)
Me.Label6.TabIndex = 5
Me.Label6.Text = \"Dec 1, 10001\"
\'
\'Timer1
\'
Me.Timer1.Enabled = True
Me.Timer1.Interval = 1
\'
\'NotifyIcon1
\'
Me.NotifyIcon1.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info
Me.NotifyIcon1.BalloonTipText = \"Getting\"
Me.NotifyIcon1.BalloonTipTitle = \"The Times for Calgary and Shenzhen\"
Me.NotifyIcon1.Icon = CType(resources.GetObject(\"NotifyIcon1.Icon\"), System.Drawing.Icon)
Me.NotifyIcon1.Text = \"NotifyIcon1\"
Me.NotifyIcon1.Visible = True
\'
\'Form1
\'
Me.AutoScaleDimensions = New System.Drawing.SizeF(17.0!, 36.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(571, 72)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Font = New System.Drawing.Font(\"Microsoft Sans Serif\", 18.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Me.Margin = New System.Windows.Forms.Padding(6, 7, 6, 7)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = \"Form1\"
Me.Opacity = 0.68
Me.Text = \"Time Viewer\"
Me.WindowState = System.Windows.Forms.FormWindowState.Minimized
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents NotifyIcon1 As System.Windows.Forms.NotifyIcon
End Class
==================================End Code==================================
2. Create Code
Just use the code I have:
==================================Start Code==================================
Public Class Form1
Declare Function Beep Lib \"kernel32.dll\" Alias \"Beep\" (ByVal freq As Integer, ByVal duration As Integer) As Boolean
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim calt As Date = Now
\'If Now.Millisecond = 0 Then Call Beep(1000, 15)
Dim szt As Date = Now.AddHours(15)
Label3.Text = tdf(calt.Hour) & \":\" & tdf(calt.Minute) & \":\" & tdf(calt.Second)
Label5.Text = GMN(calt.Month) & \" \" & tdf(calt.Day) & \", \" & tdf(calt.Year)
Label4.Text = tdf(szt.Hour) & \":\" & tdf(szt.Minute) & \":\" & tdf(szt.Second)
Label6.Text = GMN(szt.Month) & \" \" & tdf(szt.Day) & \", \" & tdf(szt.Year)
If calt.Millisecond = 0 Then
NotifyIcon1.BalloonTipText = \"Mountain Time (GMT - 7) \" & Label5.Text & \" \" & Label3.Text & Chr(13) & Chr(10) & \"China (GMT + 8) \" & Label6.Text & \" \" & Label4.Text
NotifyIcon1.ShowBalloonTip(100)
End If
End Sub
Function GMN(ByVal mnt As Integer) As String
Dim str As String
Select Case mnt
Case 1
\'str = \"Janurary\"
str = \"Jan\"
Case 2
\'str = \"Feburary\"
str = \"Feb\"
Case 3
\'str = \"March\"
str = \"Mar\"
Case 4
\'str = \"April\"
str = \"Apr\"
Case 5
\'str = \"May\"
Case 6
\'str = \"June\"
str = \"Jun\"
Case 7
\'str = \"July\"
str = \"Jul\"
Case 8
\'str = \"August\"
str = \"Aug\"
Case 9
\'str = \"September\"
str = \"Sep\"
Case 10
\'str = \"October\"
str = \"Oct\"
Case 11
\'str = \"November\"
str = \"Nov\"
Case 12
\'str = \"December\"
str = \"Dec\"
End Select
Return str
End Function
ReadOnly Property tdf(ByVal t As Integer) As String
Get
If t.ToString.Length = 1 Then Return \"0\" & t.ToString Else : Return t.ToString
End Get
End Property
Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
End
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Height = 0
Me.Width = 0
End Sub
End Class
==================================End Code==================================
3. Adjust to your needs:
1. Replace Mountain Time with your time zone, and GMT+/-* and replace China with any time zone, and GMT+/-*
2. Now you can start to replace AddHours(15) with AddHours(*)
3. The * is supposed to be difference between the two times!
4. Compile it
Just compile it, and take the .exe from the debugged directory!
4. Learn how to use it.
1. Double click on the application to start it up.
2. It will popup a balloon updating both time zone\'s time!
3. Double Click on the Icon to Close it.
4. If it doesn\'t close, just click it 4 times
5. Enjoy!

-----------------------------------------------------------------------------------------
Test Out My Attachment!
Edit:
doh! I forgot to add an attachment!
 
Last edited:
Status
Not open for further replies.
Top