home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / csstray / csstray.exe / _SETUP.1 / frmEx3.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-01-25  |  4.5 KB  |  120 lines

  1. VERSION 5.00
  2. Object = "{0DE92B77-C272-11D1-82B4-E5132F8CF155}#8.0#0"; "csstray.ocx"
  3. Begin VB.Form frmEx3 
  4.    Caption         =   "SysTray Example #3"
  5.    ClientHeight    =   2025
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   5265
  9.    Icon            =   "frmEx3.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    ScaleHeight     =   2025
  13.    ScaleWidth      =   5265
  14.    ShowInTaskbar   =   0   'False
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin VB.CommandButton cmdClose 
  17.       Caption         =   "&Close"
  18.       Height          =   375
  19.       Left            =   4080
  20.       TabIndex        =   0
  21.       Top             =   1560
  22.       Width           =   1095
  23.    End
  24.    Begin csSysTrayCtl.csSysTray csSysTray1 
  25.       Left            =   2760
  26.       Top             =   1320
  27.       _ExtentX        =   2064
  28.       _ExtentY        =   1111
  29.       TrayIcon        =   "frmEx3.frx":0442
  30.       TrayTip         =   "Click me to see the window again!"
  31.       TrayVisible     =   0   'False
  32.       p_RegCode       =   "frmEx3.frx":0894
  33.    End
  34.    Begin VB.Label Label3 
  35.       Caption         =   "This example application shows just how easy it is to use the SysTray control in your own application."
  36.       BeginProperty Font 
  37.          Name            =   "MS Sans Serif"
  38.          Size            =   8.25
  39.          Charset         =   0
  40.          Weight          =   700
  41.          Underline       =   0   'False
  42.          Italic          =   0   'False
  43.          Strikethrough   =   0   'False
  44.       EndProperty
  45.       Height          =   495
  46.       Left            =   120
  47.       TabIndex        =   2
  48.       Top             =   120
  49.       Width           =   5055
  50.    End
  51.    Begin VB.Label Label4 
  52.       Caption         =   $"frmEx3.frx":08B4
  53.       BeginProperty Font 
  54.          Name            =   "MS Sans Serif"
  55.          Size            =   8.25
  56.          Charset         =   0
  57.          Weight          =   700
  58.          Underline       =   0   'False
  59.          Italic          =   0   'False
  60.          Strikethrough   =   0   'False
  61.       EndProperty
  62.       Height          =   780
  63.       Left            =   120
  64.       TabIndex        =   1
  65.       Top             =   600
  66.       Width           =   5055
  67.    End
  68. Attribute VB_Name = "frmEx3"
  69. Attribute VB_GlobalNameSpace = False
  70. Attribute VB_Creatable = False
  71. Attribute VB_PredeclaredId = True
  72. Attribute VB_Exposed = False
  73. Option Explicit
  74. 'Example program for SysTray Control
  75. '(C) Copyright 1998 Charon Software, All Rights Reserved
  76. 'You may use or modify this code in any way you see fit.
  77. 'Charon Software takes no responsibility for what you may
  78. 'do with this or any modification of this code.
  79. 'This example shows how easy it is to change the default
  80. 'minimize behavior to minimize to the system tray instead!
  81. Private Sub cmdClose_Click()
  82.     'pretty simple; just unload our form.  The system tray
  83.     'icons will go away automatically!
  84.     Unload Me
  85. End Sub
  86. Private Sub csSysTray1_AfterMinimize(hWnd As Long)
  87.     'the AfterMinimize event occurs after the user clicked
  88.     'the minimize button on the window.  When we "minimize"
  89.     'to the system tray, we actually just hide the window.
  90.     'we know we're "zoomed" to the tray, so just show the icon.
  91.     csSysTray1.TrayShow
  92. End Sub
  93. 'When the user clicks on the icon, we want to zoom the window
  94. 'back to its regular spot.  However, we don't want the system
  95. 'tray icon to disappear until the window is fully restored.
  96. 'If the user were to double-click really fast, they could
  97. 'launch the zoom animation twice!  So, we create a static
  98. 'variable here to exit the event sub up front if we are
  99. 'processing inside of it.
  100. '**************
  101. Private Sub csSysTray1_Click()
  102. Static sProcessing As Boolean
  103.     If sProcessing = True Then Exit Sub 'if we're still zooming,
  104.                                         'don't do it again!
  105.     sProcessing = True 'okay, we're starting to zoom the window.
  106.     'if the user clicks on the icon, zoom our form from the
  107.     'tray and remove the icon!
  108.     csSysTray1.ZoomFromTray Me.hWnd
  109.     csSysTray1.TrayHide
  110.     sProcessing = False 'we're done processing now :)
  111. End Sub
  112. Private Sub Form_Load()
  113.     'the following function will instruct the SysTray control
  114.     'to "watch" our window.  If the user clicks on the minimize
  115.     'button, the window will be zoomed to the system tray and
  116.     'hidden instead.  We can stop watching the window with the
  117.     'RemoveMinimizeWatch method.
  118.     csSysTray1.AddMinimizeWatch Me.hWnd
  119. End Sub
  120.