home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / itv251 / vbsystra.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-09-11  |  9.9 KB  |  305 lines

  1. VERSION 4.00
  2. Begin VB.Form SysTray 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Icon Tray DLL Sampler"
  5.    ClientHeight    =   3372
  6.    ClientLeft      =   2016
  7.    ClientTop       =   1668
  8.    ClientWidth     =   4188
  9.    ClipControls    =   0   'False
  10.    Height          =   3744
  11.    Left            =   1968
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   3372
  16.    ScaleWidth      =   4188
  17.    ShowInTaskbar   =   0   'False
  18.    Top             =   1344
  19.    Width           =   4284
  20.    Begin VB.CommandButton cmd 
  21.       Caption         =   "Set"
  22.       Height          =   315
  23.       Index           =   5
  24.       Left            =   120
  25.       TabIndex        =   11
  26.       Top             =   1200
  27.       Width           =   945
  28.    End
  29.    Begin VB.CommandButton cmdBrowse 
  30.       Caption         =   ". . ."
  31.       Height          =   300
  32.       Left            =   3120
  33.       TabIndex        =   10
  34.       Top             =   840
  35.       Width           =   375
  36.    End
  37.    Begin VB.TextBox txtIcon 
  38.       Height          =   300
  39.       Left            =   120
  40.       TabIndex        =   9
  41.       Top             =   840
  42.       Width           =   2940
  43.    End
  44.    Begin VB.Timer Timer1 
  45.       Interval        =   1
  46.       Left            =   960
  47.       Top             =   0
  48.    End
  49.    Begin VB.CommandButton cmd 
  50.       Caption         =   "Clear"
  51.       Height          =   315
  52.       Index           =   4
  53.       Left            =   1200
  54.       TabIndex        =   6
  55.       Top             =   2280
  56.       Width           =   945
  57.    End
  58.    Begin VB.CommandButton cmd 
  59.       Caption         =   "Set"
  60.       Height          =   315
  61.       Index           =   3
  62.       Left            =   120
  63.       TabIndex        =   5
  64.       Top             =   2280
  65.       Width           =   945
  66.    End
  67.    Begin VB.CommandButton cmd 
  68.       Caption         =   "Hide"
  69.       Height          =   315
  70.       Index           =   1
  71.       Left            =   3120
  72.       TabIndex        =   4
  73.       Top             =   120
  74.       Width           =   945
  75.    End
  76.    Begin VB.TextBox txtToolTips 
  77.       Height          =   300
  78.       Left            =   120
  79.       MaxLength       =   63
  80.       TabIndex        =   3
  81.       Top             =   1920
  82.       Width           =   2940
  83.    End
  84.    Begin VB.CheckBox cEnable 
  85.       Caption         =   "Enable"
  86.       Height          =   255
  87.       Left            =   120
  88.       TabIndex        =   0
  89.       Top             =   240
  90.       Width           =   870
  91.    End
  92.    Begin VB.CommandButton cmd 
  93.       Caption         =   "End"
  94.       Height          =   315
  95.       Index           =   0
  96.       Left            =   3120
  97.       TabIndex        =   1
  98.       Top             =   480
  99.       Width           =   945
  100.    End
  101.    Begin VB.Label lblRecent 
  102.       BackColor       =   &H00FFFFFF&
  103.       BorderStyle     =   1  'Fixed Single
  104.       Height          =   255
  105.       Left            =   120
  106.       TabIndex        =   13
  107.       Top             =   3000
  108.       Width           =   2895
  109.    End
  110.    Begin VB.Label Label3 
  111.       AutoSize        =   -1  'True
  112.       Caption         =   "Most Recent Event:"
  113.       Height          =   195
  114.       Left            =   120
  115.       TabIndex        =   12
  116.       Top             =   2760
  117.       Width           =   1425
  118.    End
  119.    Begin MSComDlg.CommonDialog CD1 
  120.       Left            =   1440
  121.       Top             =   0
  122.       _Version        =   65536
  123.       _ExtentX        =   677
  124.       _ExtentY        =   677
  125.       _StockProps     =   0
  126.       DialogTitle     =   "Specify Icon File"
  127.       Filter          =   "*.ico"
  128.       InitDir         =   "C:\"
  129.    End
  130.    Begin VB.Label Label2 
  131.       Caption         =   "Icon:"
  132.       Height          =   255
  133.       Left            =   120
  134.       TabIndex        =   8
  135.       Top             =   600
  136.       Width           =   375
  137.    End
  138.    Begin VB.Label lblMessage 
  139.       Alignment       =   2  'Center
  140.       BackStyle       =   0  'Transparent
  141.       Height          =   495
  142.       Left            =   120
  143.       TabIndex        =   7
  144.       Top             =   4500
  145.       Width           =   3975
  146.    End
  147.    Begin VB.Image Image1 
  148.       Appearance      =   0  'Flat
  149.       Height          =   384
  150.       Left            =   1560
  151.       Picture         =   "VBSystray.frx":0000
  152.       Top             =   120
  153.       Width           =   384
  154.    End
  155.    Begin VB.Label Label1 
  156.       Caption         =   "Tool Tip Text:"
  157.       Height          =   195
  158.       Index           =   0
  159.       Left            =   120
  160.       TabIndex        =   2
  161.       Top             =   1680
  162.       Width           =   1095
  163.    End
  164.    Begin VB.Menu mnuOptions 
  165.       Caption         =   "&Options"
  166.       Visible         =   0   'False
  167.       Begin VB.Menu mOpts 
  168.          Caption         =   "Show Form"
  169.          Index           =   0
  170.       End
  171.       Begin VB.Menu mOpts 
  172.          Caption         =   "-"
  173.          Index           =   2
  174.       End
  175.       Begin VB.Menu mOpts 
  176.          Caption         =   "End"
  177.          Index           =   3
  178.       End
  179.    End
  180. Attribute VB_Name = "SysTray"
  181. Attribute VB_Creatable = False
  182. Attribute VB_Exposed = False
  183. Option Explicit
  184. Public IconTray As New Icon
  185. Private Sub cEnable_Click()
  186.  'action based on checked value
  187.   If cEnable.Value = 1 Then
  188.         IconTray.Icon = Image1.Picture
  189.         IconTray.ToolTip = txtToolTips.Text
  190.         IconTray.Add
  191.   Else: IconTray.Remove
  192.   End If
  193.  'enable buttons if applicable
  194.   cmd(1).Enabled = cEnable.Value = 1
  195.   cmd(3).Enabled = cEnable.Value = 1
  196.   cmd(5).Enabled = cEnable.Value = 1
  197.   lblMessage.Visible = cEnable.Value = 1
  198. End Sub
  199. Private Sub cmd_Click(Index As Integer)
  200.   Select Case Index%
  201.     Case 0:  'make sure the systray item is removed.
  202.               IconTray.Remove
  203.              'unload and end
  204.               Unload Me
  205.               End
  206.     Case 1:  'hide the main form. Only enabled
  207.              'if the Enabled box is checked.
  208.               Me.Hide
  209.     Case 3:  'set the new Tool Tip text
  210.               IconTray.ToolTip = txtToolTips.Text
  211.               IconTray.Update
  212.     Case 4:  'clear the text
  213.               txtToolTips.Text = ""
  214.               txtToolTips.SetFocus
  215.     Case 5:  'set the icon file
  216.               Image1.Picture = LoadPicture(txtIcon.Text)
  217.               IconTray.Icon = Image1.Picture
  218.               'IconTray.ToolTip = txtToolTips.Text
  219.               IconTray.Update
  220.   End Select
  221. End Sub
  222. Private Sub cmdBrowse_Click()
  223.     'Shows the Common Dialog's "Open" Box
  224.     CD1.Filter = "Icons(*.ico)|*.ico|All Files (*.*)|*.*"
  225.     CD1.ShowOpen
  226.     'sets the Icon text field to the Common Dialogs filename
  227.     If CD1.filename <> "" Then
  228.     txtIcon.Text = CD1.filename
  229.     End If
  230. End Sub
  231. Private Sub Form_Load()
  232.   On Error GoTo ErrorHandler
  233.  'centre the form
  234.   Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
  235.   'set button startup states
  236.    cEnable.Value = 0
  237.   'set tool tip text startup state
  238.    txtToolTips.Text = "Icon Tray DLL Sampler"
  239.    IconTray.ToolTip = txtToolTips.Text
  240.   'set icon file
  241.    txtIcon.Text = "Earth.ico"
  242.   'set command button startup states
  243.    cmd(1).Enabled = cEnable.Value = 1
  244.    cmd(3).Enabled = cEnable.Value = 1
  245.    cmd(5).Enabled = cEnable.Value = 1
  246.   'set message label startup state
  247.    lblMessage.Visible = cEnable.Value = 1
  248.    Call cEnable_Click
  249.    Exit Sub
  250. ErrorHandler:
  251.     MsgBox Error(Err)
  252. End Sub
  253. Private Sub Image1_Click()
  254. 'image holds the icon to display
  255. End Sub
  256. Private Sub mnuOptions_Click()
  257. 'the menu that is called in the form's mouseDown
  258. End Sub
  259. Private Sub mOpts_Click(Index As Integer)
  260. '0: reshow the form if hidden
  261. '3: end the app
  262.   Select Case Index%
  263.     Case 0: Me.Show
  264.     Case 3: cmd_Click 0
  265.   End Select
  266. End Sub
  267. Private Sub Timer1_Timer()
  268.    'set the most recent event
  269.    'If IconTray.Status = "LeftClickEvent" Then lblRecent.Caption = "Left Click": Exit Sub
  270.    'lblRecent.Caption = IconTray.Status
  271.    'Exit Sub
  272.    If IconTray.Status <> "Nothing" Then
  273.        If IconTray.Status = "LeftClickEvent" Then lblRecent.Caption = "Left Click"
  274.        If IconTray.Status = "LeftDoubleClickEvent" Then lblRecent.Caption = "Double-Left Click"
  275.        If IconTray.Status = "RightClickEvent" Then lblRecent.Caption = "Right Click"
  276.        If IconTray.Status = "RightDoubleClickEvent" Then lblRecent.Caption = "Double-Right Click"
  277.        If IconTray.Status = "MouseMoveEvent" Then lblRecent.Caption = "Mouse Moved Over"
  278.    End If
  279.    ' The below If/Then/Else statement controls code if the mouse moves over icon
  280.    If IconTray.Status = "MouseMoveEvent" Then
  281.         
  282.         IconTray.StatusOut
  283.     End If
  284.    ' The below If/Then/Else statement controls code for Right Clicking On the Icon
  285.    If IconTray.Status = "RightClickEvent" Then
  286.         PopupMenu mnuOptions
  287.         IconTray.StatusOut 'NEVER delete this line!  It is essential to the any program using IconTray.dll
  288.    End If
  289.    ' The below If/Then/Else statement controls code for Left Clicking On the Icon
  290.    If IconTray.Status = "LeftClickEvent" Then
  291.             'IconTray.StatusOut 'NEVER delete this line!  It is essential to the any program using IconTray.dll
  292.    End If
  293.    ' The below If/Then/Else statement controls code for Left-Double Clicking On the Icon
  294.    If IconTray.Status = "LeftDoubleClickEvent" Then
  295.             IconTray.StatusOut 'NEVER delete this line!  It is essential to the any program using IconTray.dll
  296.    End If
  297.    ' The below If/Then/Else statement controls code for Right-Double Clicking On the Icon
  298.    If IconTray.Status = "RightDoubleClickEvent" Then
  299.             IconTray.StatusOut 'NEVER delete this line!  It is essential to the any program using IconTray.dll
  300.    End If
  301. End Sub
  302. Private Sub txtToolTips_Change()
  303.     cmd(3).Enabled = cEnable.Value = 1
  304. End Sub
  305.