home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / systrayc / csstray.exe / _SETUP.1 / frmEx1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-08-19  |  10.3 KB  |  288 lines

  1. VERSION 5.00
  2. Object = "{0DE92B77-C272-11D1-82B4-E5132F8CF155}#3.1#0"; "CSSTRAY.OCX"
  3. Begin VB.Form frmEx1 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "SysTray Example Application #1"
  6.    ClientHeight    =   5895
  7.    ClientLeft      =   150
  8.    ClientTop       =   435
  9.    ClientWidth     =   5535
  10.    Icon            =   "frmEx1.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    ScaleHeight     =   5895
  14.    ScaleWidth      =   5535
  15.    StartUpPosition =   1  'CenterOwner
  16.    Begin csSysTrayCtl.csSysTray csSysTray2 
  17.       Left            =   3000
  18.       Top             =   2280
  19.       _ExtentX        =   2064
  20.       _ExtentY        =   1111
  21.       TrayIcon        =   "frmEx1.frx":0442
  22.       TrayTip         =   "Look; a second icon!"
  23.       TrayVisible     =   0   'False
  24.    End
  25.    Begin VB.CheckBox chkSecondIcon 
  26.       Caption         =   "Show another icon in the system tray!"
  27.       Height          =   255
  28.       Left            =   120
  29.       TabIndex        =   9
  30.       Top             =   5580
  31.       Width           =   3855
  32.    End
  33.    Begin VB.CheckBox chkShowIcon 
  34.       Caption         =   "Show the icon in the system tray."
  35.       Height          =   255
  36.       Left            =   120
  37.       TabIndex        =   8
  38.       Top             =   5340
  39.       Width           =   3855
  40.    End
  41.    Begin VB.TextBox txtTooltip 
  42.       Height          =   345
  43.       Left            =   120
  44.       TabIndex        =   0
  45.       Top             =   4920
  46.       Width           =   3735
  47.    End
  48.    Begin csSysTrayCtl.csSysTray csSysTray1 
  49.       Left            =   4200
  50.       Top             =   2280
  51.       _ExtentX        =   2064
  52.       _ExtentY        =   1111
  53.       TrayIcon        =   "frmEx1.frx":0894
  54.       TrayTip         =   "SysTray Example Application #1"
  55.    End
  56.    Begin VB.CommandButton cmdClose 
  57.       Cancel          =   -1  'True
  58.       Caption         =   "&Close"
  59.       Default         =   -1  'True
  60.       Height          =   375
  61.       Left            =   4320
  62.       TabIndex        =   2
  63.       Top             =   5400
  64.       Width           =   1095
  65.    End
  66.    Begin VB.ListBox lstEvents 
  67.       Height          =   2010
  68.       Left            =   120
  69.       TabIndex        =   1
  70.       Top             =   2520
  71.       Width           =   5295
  72.    End
  73.    Begin VB.Label Label1 
  74.       AutoSize        =   -1  'True
  75.       Caption         =   "Type the tooltip for the SysTray icon below:"
  76.       BeginProperty Font 
  77.          Name            =   "MS Sans Serif"
  78.          Size            =   8.25
  79.          Charset         =   0
  80.          Weight          =   700
  81.          Underline       =   0   'False
  82.          Italic          =   0   'False
  83.          Strikethrough   =   0   'False
  84.       EndProperty
  85.       Height          =   195
  86.       Left            =   120
  87.       TabIndex        =   7
  88.       Top             =   4680
  89.       Width           =   3735
  90.    End
  91.    Begin VB.Label Label5 
  92.       Caption         =   $"frmEx1.frx":0CE6
  93.       BeginProperty Font 
  94.          Name            =   "MS Sans Serif"
  95.          Size            =   8.25
  96.          Charset         =   0
  97.          Weight          =   700
  98.          Underline       =   0   'False
  99.          Italic          =   0   'False
  100.          Strikethrough   =   0   'False
  101.       EndProperty
  102.       Height          =   1125
  103.       Left            =   120
  104.       TabIndex        =   6
  105.       Top             =   1320
  106.       Width           =   5055
  107.    End
  108.    Begin VB.Label Label4 
  109.       Caption         =   $"frmEx1.frx":0DF1
  110.       BeginProperty Font 
  111.          Name            =   "MS Sans Serif"
  112.          Size            =   8.25
  113.          Charset         =   0
  114.          Weight          =   700
  115.          Underline       =   0   'False
  116.          Italic          =   0   'False
  117.          Strikethrough   =   0   'False
  118.       EndProperty
  119.       Height          =   665
  120.       Left            =   120
  121.       TabIndex        =   5
  122.       Top             =   600
  123.       Width           =   5055
  124.    End
  125.    Begin VB.Label Label3 
  126.       Caption         =   "This example application shows just how easy it is to use the SysTray control in your own application."
  127.       BeginProperty Font 
  128.          Name            =   "MS Sans Serif"
  129.          Size            =   8.25
  130.          Charset         =   0
  131.          Weight          =   700
  132.          Underline       =   0   'False
  133.          Italic          =   0   'False
  134.          Strikethrough   =   0   'False
  135.       EndProperty
  136.       Height          =   495
  137.       Left            =   120
  138.       TabIndex        =   4
  139.       Top             =   120
  140.       Width           =   5055
  141.    End
  142.    Begin VB.Label Label2 
  143.       Caption         =   "^^ EVENTS ^^"
  144.       BeginProperty Font 
  145.          Name            =   "MS Sans Serif"
  146.          Size            =   8.25
  147.          Charset         =   0
  148.          Weight          =   700
  149.          Underline       =   0   'False
  150.          Italic          =   0   'False
  151.          Strikethrough   =   0   'False
  152.       EndProperty
  153.       Height          =   255
  154.       Left            =   4080
  155.       TabIndex        =   3
  156.       Top             =   4680
  157.       Width           =   1335
  158.    End
  159.    Begin VB.Menu mnuSysTray 
  160.       Caption         =   "SysTray"
  161.       Visible         =   0   'False
  162.       Begin VB.Menu mnuSysTrayAbout 
  163.          Caption         =   "&About SysTray"
  164.       End
  165.       Begin VB.Menu mnuSysTraySep 
  166.          Caption         =   "-"
  167.       End
  168.       Begin VB.Menu mnuSysTrayClose 
  169.          Caption         =   "&Close Program"
  170.       End
  171.    End
  172. Attribute VB_Name = "frmEx1"
  173. Attribute VB_GlobalNameSpace = False
  174. Attribute VB_Creatable = False
  175. Attribute VB_PredeclaredId = True
  176. Attribute VB_Exposed = False
  177. Option Explicit
  178. 'Example program for SysTray Control
  179. '(C) Copyright 1998 Charon Software, All Rights Reserved
  180. 'You may use or modify this code in any way you see fit.
  181. 'Charon Software takes no responsibility for what you may
  182. 'do with this or any modification of this code.
  183. Private Sub chkSecondIcon_Click()
  184.     'if the user clicks on this checkbox, toggle the visible
  185.     'property of the system tray icon.
  186.     csSysTray2.TrayVisible = chkSecondIcon.Value
  187. End Sub
  188. Private Sub chkShowIcon_Click()
  189.     'if the user clicks on this checkbox, toggle the visible
  190.     'property of the system tray icon.
  191.     csSysTray1.TrayVisible = chkShowIcon.Value
  192. End Sub
  193. Private Sub cmdClose_Click()
  194.     'pretty self-explanatory; just unload the form.  The system
  195.     'tray icons will go away automatically!
  196.     Unload Me
  197. End Sub
  198. Private Sub csSysTray1_Click()
  199.     'for this example, we report the event in a listbox.
  200.     lstEvents.AddItem "Event: Click"
  201.     lstEvents.ListIndex = lstEvents.ListCount - 1
  202. End Sub
  203. Private Sub csSysTray1_DblClick()
  204.     'for this example, we report the event in a listbox.
  205.     lstEvents.AddItem "Event: DblClick"
  206.     lstEvents.ListIndex = lstEvents.ListCount - 1
  207. End Sub
  208. Private Sub csSysTray1_MiddleClick()
  209.     'for this example, we report the event in a listbox.
  210.     lstEvents.AddItem "Event: MiddleClick"
  211.     lstEvents.ListIndex = lstEvents.ListCount - 1
  212. End Sub
  213. Private Sub csSysTray1_MiddleDblClick()
  214.     'for this example, we report the event in a listbox.
  215.     lstEvents.AddItem "Event: MiddleDblClick"
  216.     lstEvents.ListIndex = lstEvents.ListCount - 1
  217. End Sub
  218. Private Sub csSysTray1_MouseDown(Button As Integer)
  219.     'for this example, we report the event in a listbox.
  220.     lstEvents.AddItem "Event: MouseDown, Button:" + Str(Button)
  221.     lstEvents.ListIndex = lstEvents.ListCount - 1
  222. End Sub
  223. Private Sub csSysTray1_MouseMove()
  224.     'for this example, we report the event in a listbox.
  225.     lstEvents.AddItem "Event: MouseMove"
  226.     lstEvents.ListIndex = lstEvents.ListCount - 1
  227. End Sub
  228. Private Sub csSysTray1_MouseUp(Button As Integer)
  229.     'for this example, we report the event in a listbox.
  230.     lstEvents.AddItem "Event: MouseUp, Button:" + Str(Button)
  231.     lstEvents.ListIndex = lstEvents.ListCount - 1
  232. End Sub
  233. Private Sub csSysTray1_RightClick()
  234.     'for this example, we report the event in a listbox.
  235.     lstEvents.AddItem "Event: RightClick"
  236.     lstEvents.ListIndex = lstEvents.ListCount - 1
  237.     'since the user right-clicked the icon, pop up a menu!
  238.     'the vbPopupMenuRightButton flag allows both our right and
  239.     'left mouse buttons to be able to choose menu items, instead
  240.     'of just the left button.
  241.     'note that we use the SysTray's PopupMenu method.  Using this
  242.     'method will ensure that our popup menu goes away when it should.
  243.     csSysTray1.PopupMenu mnuSysTray, vbPopupMenuRightButton
  244.     'you could also add the "default" menu item as the last parameter
  245.     'in PopUpMenu. That would indicate that single left-clicking the
  246.     'icon would do the same thing. It's not included here because
  247.     'double left-clicking just shows your mouse events instead.
  248.     'To do this, you would use a command like the following:
  249. '    csSysTray1.PopupMenu mnuSysTray, vbPopupMenuRightButton, , , mnuSysTrayAbout
  250. End Sub
  251. Private Sub csSysTray1_RightDblClick()
  252.     'for this example, we report the event in a listbox.
  253.     lstEvents.AddItem "Event: RightDblClick"
  254.     lstEvents.ListIndex = lstEvents.ListCount - 1
  255. End Sub
  256. Private Sub Form_Load()
  257.     'here, we do some initializion.  We set the text of
  258.     'of our textbox to the current tooltip of the system
  259.     'tray icon.  We also set the checked properties of our
  260.     'checkboxes to the appropriate values.
  261.     txtTooltip.Text = csSysTray1.TrayTip
  262.     If csSysTray1.TrayVisible = True Then
  263.         chkShowIcon.Value = vbChecked
  264.     Else
  265.         chkShowIcon.Value = vbUnchecked
  266.     End If
  267.     If csSysTray2.TrayVisible = True Then
  268.         chkSecondIcon.Value = vbChecked
  269.     Else
  270.         chkSecondIcon.Value = vbUnchecked
  271.     End If
  272.     txtTooltip.SelStart = Len(txtTooltip.Text)
  273. End Sub
  274. Private Sub Form_Unload(Cancel As Integer)
  275.     csSysTray1.ZoomToTray Me.hWnd
  276. End Sub
  277. Private Sub mnuSysTrayAbout_Click()
  278.     csSysTray1.AboutBox
  279. End Sub
  280. Private Sub mnuSysTrayClose_Click()
  281.     'simple enough: close down our program.
  282.     Unload Me
  283. End Sub
  284. Private Sub txtTooltip_Change()
  285.     'change the tooltip on the system tray icon.
  286.     csSysTray1.TrayTip = txtTooltip.Text
  287. End Sub
  288.