home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form SysTray
- BorderStyle = 3 'Fixed Dialog
- Caption = "Icon Tray DLL Sampler"
- ClientHeight = 3372
- ClientLeft = 2016
- ClientTop = 1668
- ClientWidth = 4188
- ClipControls = 0 'False
- Height = 3744
- Left = 1968
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 3372
- ScaleWidth = 4188
- ShowInTaskbar = 0 'False
- Top = 1344
- Width = 4284
- Begin VB.CommandButton cmd
- Caption = "Set"
- Height = 315
- Index = 5
- Left = 120
- TabIndex = 11
- Top = 1200
- Width = 945
- End
- Begin VB.CommandButton cmdBrowse
- Caption = ". . ."
- Height = 300
- Left = 3120
- TabIndex = 10
- Top = 840
- Width = 375
- End
- Begin VB.TextBox txtIcon
- Height = 300
- Left = 120
- TabIndex = 9
- Top = 840
- Width = 2940
- End
- Begin VB.Timer Timer1
- Interval = 1
- Left = 960
- Top = 0
- End
- Begin VB.CommandButton cmd
- Caption = "Clear"
- Height = 315
- Index = 4
- Left = 1200
- TabIndex = 6
- Top = 2280
- Width = 945
- End
- Begin VB.CommandButton cmd
- Caption = "Set"
- Height = 315
- Index = 3
- Left = 120
- TabIndex = 5
- Top = 2280
- Width = 945
- End
- Begin VB.CommandButton cmd
- Caption = "Hide"
- Height = 315
- Index = 1
- Left = 3120
- TabIndex = 4
- Top = 120
- Width = 945
- End
- Begin VB.TextBox txtToolTips
- Height = 300
- Left = 120
- MaxLength = 63
- TabIndex = 3
- Top = 1920
- Width = 2940
- End
- Begin VB.CheckBox cEnable
- Caption = "Enable"
- Height = 255
- Left = 120
- TabIndex = 0
- Top = 240
- Width = 870
- End
- Begin VB.CommandButton cmd
- Caption = "End"
- Height = 315
- Index = 0
- Left = 3120
- TabIndex = 1
- Top = 480
- Width = 945
- End
- Begin VB.Label lblRecent
- BackColor = &H00FFFFFF&
- BorderStyle = 1 'Fixed Single
- Height = 255
- Left = 120
- TabIndex = 13
- Top = 3000
- Width = 2895
- End
- Begin VB.Label Label3
- AutoSize = -1 'True
- Caption = "Most Recent Event:"
- Height = 195
- Left = 120
- TabIndex = 12
- Top = 2760
- Width = 1425
- End
- Begin MSComDlg.CommonDialog CD1
- Left = 1440
- Top = 0
- _Version = 65536
- _ExtentX = 677
- _ExtentY = 677
- _StockProps = 0
- DialogTitle = "Specify Icon File"
- Filter = "*.ico"
- InitDir = "C:\"
- End
- Begin VB.Label Label2
- Caption = "Icon:"
- Height = 255
- Left = 120
- TabIndex = 8
- Top = 600
- Width = 375
- End
- Begin VB.Label lblMessage
- Alignment = 2 'Center
- BackStyle = 0 'Transparent
- Height = 495
- Left = 120
- TabIndex = 7
- Top = 4500
- Width = 3975
- End
- Begin VB.Image Image1
- Appearance = 0 'Flat
- Height = 384
- Left = 1560
- Picture = "VBSystray.frx":0000
- Top = 120
- Width = 384
- End
- Begin VB.Label Label1
- Caption = "Tool Tip Text:"
- Height = 195
- Index = 0
- Left = 120
- TabIndex = 2
- Top = 1680
- Width = 1095
- End
- Begin VB.Menu mnuOptions
- Caption = "&Options"
- Visible = 0 'False
- Begin VB.Menu mOpts
- Caption = "Show Form"
- Index = 0
- End
- Begin VB.Menu mOpts
- Caption = "-"
- Index = 2
- End
- Begin VB.Menu mOpts
- Caption = "End"
- Index = 3
- End
- End
- Attribute VB_Name = "SysTray"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- Public IconTray As New Icon
- Private Sub cEnable_Click()
- 'action based on checked value
- If cEnable.Value = 1 Then
- IconTray.Icon = Image1.Picture
- IconTray.ToolTip = txtToolTips.Text
- IconTray.Add
- Else: IconTray.Remove
- End If
- 'enable buttons if applicable
- cmd(1).Enabled = cEnable.Value = 1
- cmd(3).Enabled = cEnable.Value = 1
- cmd(5).Enabled = cEnable.Value = 1
- lblMessage.Visible = cEnable.Value = 1
- End Sub
- Private Sub cmd_Click(Index As Integer)
- Select Case Index%
- Case 0: 'make sure the systray item is removed.
- IconTray.Remove
- 'unload and end
- Unload Me
- End
- Case 1: 'hide the main form. Only enabled
- 'if the Enabled box is checked.
- Me.Hide
- Case 3: 'set the new Tool Tip text
- IconTray.ToolTip = txtToolTips.Text
- IconTray.Update
- Case 4: 'clear the text
- txtToolTips.Text = ""
- txtToolTips.SetFocus
- Case 5: 'set the icon file
- Image1.Picture = LoadPicture(txtIcon.Text)
- IconTray.Icon = Image1.Picture
- 'IconTray.ToolTip = txtToolTips.Text
- IconTray.Update
- End Select
- End Sub
- Private Sub cmdBrowse_Click()
- 'Shows the Common Dialog's "Open" Box
- CD1.Filter = "Icons(*.ico)|*.ico|All Files (*.*)|*.*"
- CD1.ShowOpen
- 'sets the Icon text field to the Common Dialogs filename
- If CD1.filename <> "" Then
- txtIcon.Text = CD1.filename
- End If
- End Sub
- Private Sub Form_Load()
- On Error GoTo ErrorHandler
- 'centre the form
- Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
- 'set button startup states
- cEnable.Value = 0
- 'set tool tip text startup state
- txtToolTips.Text = "Icon Tray DLL Sampler"
- IconTray.ToolTip = txtToolTips.Text
- 'set icon file
- txtIcon.Text = "Earth.ico"
- 'set command button startup states
- cmd(1).Enabled = cEnable.Value = 1
- cmd(3).Enabled = cEnable.Value = 1
- cmd(5).Enabled = cEnable.Value = 1
- 'set message label startup state
- lblMessage.Visible = cEnable.Value = 1
- Call cEnable_Click
- Exit Sub
- ErrorHandler:
- MsgBox Error(Err)
- End Sub
- Private Sub Image1_Click()
- 'image holds the icon to display
- End Sub
- Private Sub mnuOptions_Click()
- 'the menu that is called in the form's mouseDown
- End Sub
- Private Sub mOpts_Click(Index As Integer)
- '0: reshow the form if hidden
- '3: end the app
- Select Case Index%
- Case 0: Me.Show
- Case 3: cmd_Click 0
- End Select
- End Sub
- Private Sub Timer1_Timer()
- 'set the most recent event
- 'If IconTray.Status = "LeftClickEvent" Then lblRecent.Caption = "Left Click": Exit Sub
- 'lblRecent.Caption = IconTray.Status
- 'Exit Sub
- If IconTray.Status <> "Nothing" Then
- If IconTray.Status = "LeftClickEvent" Then lblRecent.Caption = "Left Click"
- If IconTray.Status = "LeftDoubleClickEvent" Then lblRecent.Caption = "Double-Left Click"
- If IconTray.Status = "RightClickEvent" Then lblRecent.Caption = "Right Click"
- If IconTray.Status = "RightDoubleClickEvent" Then lblRecent.Caption = "Double-Right Click"
- If IconTray.Status = "MouseMoveEvent" Then lblRecent.Caption = "Mouse Moved Over"
- End If
- ' The below If/Then/Else statement controls code if the mouse moves over icon
- If IconTray.Status = "MouseMoveEvent" Then
-
- IconTray.StatusOut
- End If
- ' The below If/Then/Else statement controls code for Right Clicking On the Icon
- If IconTray.Status = "RightClickEvent" Then
- PopupMenu mnuOptions
- IconTray.StatusOut 'NEVER delete this line! It is essential to the any program using IconTray.dll
- End If
- ' The below If/Then/Else statement controls code for Left Clicking On the Icon
- If IconTray.Status = "LeftClickEvent" Then
- 'IconTray.StatusOut 'NEVER delete this line! It is essential to the any program using IconTray.dll
- End If
- ' The below If/Then/Else statement controls code for Left-Double Clicking On the Icon
- If IconTray.Status = "LeftDoubleClickEvent" Then
- IconTray.StatusOut 'NEVER delete this line! It is essential to the any program using IconTray.dll
- End If
- ' The below If/Then/Else statement controls code for Right-Double Clicking On the Icon
- If IconTray.Status = "RightDoubleClickEvent" Then
- IconTray.StatusOut 'NEVER delete this line! It is essential to the any program using IconTray.dll
- End If
- End Sub
- Private Sub txtToolTips_Change()
- cmd(3).Enabled = cEnable.Value = 1
- End Sub
-