home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1996 September / WIN95_09964.iso / program / ITv251.zip / VBSystray.frm < prev    next >
Text File  |  1996-09-11  |  10KB  |  363 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. End
  181. Attribute VB_Name = "SysTray"
  182. Attribute VB_Creatable = False
  183. Attribute VB_Exposed = False
  184. Option Explicit
  185. Public IconTray As New Icon
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. Private Sub cEnable_Click()
  196.  
  197.  'action based on checked value
  198.   If cEnable.Value = 1 Then
  199.         IconTray.Icon = Image1.Picture
  200.         IconTray.ToolTip = txtToolTips.Text
  201.         IconTray.Add
  202.   Else: IconTray.Remove
  203.   End If
  204.   
  205.  'enable buttons if applicable
  206.   cmd(1).Enabled = cEnable.Value = 1
  207.   cmd(3).Enabled = cEnable.Value = 1
  208.   cmd(5).Enabled = cEnable.Value = 1
  209.   lblMessage.Visible = cEnable.Value = 1
  210. End Sub
  211.  
  212.  
  213.  
  214. Private Sub cmd_Click(Index As Integer)
  215.  
  216.   Select Case Index%
  217.     Case 0:  'make sure the systray item is removed.
  218.               IconTray.Remove
  219.              'unload and end
  220.               Unload Me
  221.               End
  222.  
  223.     Case 1:  'hide the main form. Only enabled
  224.              'if the Enabled box is checked.
  225.               Me.Hide
  226.  
  227.     Case 3:  'set the new Tool Tip text
  228.               IconTray.ToolTip = txtToolTips.Text
  229.               IconTray.Update
  230.  
  231.     Case 4:  'clear the text
  232.               txtToolTips.Text = ""
  233.               txtToolTips.SetFocus
  234.  
  235.     Case 5:  'set the icon file
  236.               Image1.Picture = LoadPicture(txtIcon.Text)
  237.               IconTray.Icon = Image1.Picture
  238.               'IconTray.ToolTip = txtToolTips.Text
  239.               IconTray.Update
  240.   End Select
  241.  
  242.  
  243. End Sub
  244.  
  245.  
  246. Private Sub cmdBrowse_Click()
  247.     'Shows the Common Dialog's "Open" Box
  248.     CD1.Filter = "Icons(*.ico)|*.ico|All Files (*.*)|*.*"
  249.     CD1.ShowOpen
  250.     'sets the Icon text field to the Common Dialogs filename
  251.     If CD1.filename <> "" Then
  252.     txtIcon.Text = CD1.filename
  253.     End If
  254. End Sub
  255.  
  256.  
  257. Private Sub Form_Load()
  258.   On Error GoTo ErrorHandler
  259.  'centre the form
  260.   Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
  261.  
  262.   'set button startup states
  263.    cEnable.Value = 0
  264.  
  265.   'set tool tip text startup state
  266.    txtToolTips.Text = "Icon Tray DLL Sampler"
  267.    IconTray.ToolTip = txtToolTips.Text
  268.  
  269.   'set icon file
  270.    txtIcon.Text = "Earth.ico"
  271.  
  272.   'set command button startup states
  273.    cmd(1).Enabled = cEnable.Value = 1
  274.    cmd(3).Enabled = cEnable.Value = 1
  275.    cmd(5).Enabled = cEnable.Value = 1
  276.  
  277.   'set message label startup state
  278.    lblMessage.Visible = cEnable.Value = 1
  279.    
  280.    Call cEnable_Click
  281.    Exit Sub
  282. ErrorHandler:
  283.     MsgBox Error(Err)
  284. End Sub
  285.  
  286.  
  287. Private Sub Image1_Click()
  288. 'image holds the icon to display
  289. End Sub
  290.  
  291. Private Sub mnuOptions_Click()
  292. 'the menu that is called in the form's mouseDown
  293. End Sub
  294.  
  295.  
  296. Private Sub mOpts_Click(Index As Integer)
  297. '0: reshow the form if hidden
  298. '3: end the app
  299.  
  300.   Select Case Index%
  301.     Case 0: Me.Show
  302.     Case 3: cmd_Click 0
  303.   End Select
  304.  
  305. End Sub
  306.  
  307.  
  308.  
  309. Private Sub Timer1_Timer()
  310.    'set the most recent event
  311.    
  312.    'If IconTray.Status = "LeftClickEvent" Then lblRecent.Caption = "Left Click": Exit Sub
  313.    'lblRecent.Caption = IconTray.Status
  314.    'Exit Sub
  315.    
  316.    If IconTray.Status <> "Nothing" Then
  317.        If IconTray.Status = "LeftClickEvent" Then lblRecent.Caption = "Left Click"
  318.        If IconTray.Status = "LeftDoubleClickEvent" Then lblRecent.Caption = "Double-Left Click"
  319.        If IconTray.Status = "RightClickEvent" Then lblRecent.Caption = "Right Click"
  320.        If IconTray.Status = "RightDoubleClickEvent" Then lblRecent.Caption = "Double-Right Click"
  321.        If IconTray.Status = "MouseMoveEvent" Then lblRecent.Caption = "Mouse Moved Over"
  322.    End If
  323.    
  324.   
  325.    ' The below If/Then/Else statement controls code if the mouse moves over icon
  326.    If IconTray.Status = "MouseMoveEvent" Then
  327.         
  328.         IconTray.StatusOut
  329.     End If
  330.  
  331.    ' The below If/Then/Else statement controls code for Right Clicking On the Icon
  332.    If IconTray.Status = "RightClickEvent" Then
  333.         PopupMenu mnuOptions
  334.         IconTray.StatusOut 'NEVER delete this line!  It is essential to the any program using IconTray.dll
  335.    End If
  336.    
  337.    ' The below If/Then/Else statement controls code for Left Clicking On the Icon
  338.    If IconTray.Status = "LeftClickEvent" Then
  339.    
  340.             'IconTray.StatusOut 'NEVER delete this line!  It is essential to the any program using IconTray.dll
  341.    End If
  342.    
  343.    ' The below If/Then/Else statement controls code for Left-Double Clicking On the Icon
  344.    If IconTray.Status = "LeftDoubleClickEvent" Then
  345.    
  346.             IconTray.StatusOut 'NEVER delete this line!  It is essential to the any program using IconTray.dll
  347.    End If
  348.    
  349.    ' The below If/Then/Else statement controls code for Right-Double Clicking On the Icon
  350.    If IconTray.Status = "RightDoubleClickEvent" Then
  351.    
  352.             IconTray.StatusOut 'NEVER delete this line!  It is essential to the any program using IconTray.dll
  353.    End If
  354.  
  355. End Sub
  356.  
  357.  
  358.  
  359. Private Sub txtToolTips_Change()
  360.     cmd(3).Enabled = cEnable.Value = 1
  361. End Sub
  362.  
  363.