home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1997 August / pcpro-0897.iso / code / ProDemo1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-05-06  |  1.7 KB  |  44 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   2655
  5.    ClientLeft      =   1050
  6.    ClientTop       =   2445
  7.    ClientWidth     =   4575
  8.    Icon            =   "ProDemo1.frx":0000
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   2655
  11.    ScaleWidth      =   4575
  12. Attribute VB_Name = "Form1"
  13. Attribute VB_GlobalNameSpace = False
  14. Attribute VB_Creatable = False
  15. Attribute VB_PredeclaredId = True
  16. Attribute VB_Exposed = False
  17. Option Explicit
  18. Const TrayIconID = 9999         ' ID of our Tray Icon
  19. ' Procedure to initialize common fields of the NotifyIconData structure
  20. Private Sub InitNID(nid As NotifyIconData, ByVal TipString As String)
  21.     nid.cbSize = Len(nid)
  22.     nid.hWnd = Form1.hWnd
  23.     nid.uID = TrayIconID
  24.     nid.uFlags = Nif_Message + Nif_Icon + Nif_Tip
  25.     nid.uCallbackMessage = TrayCallback
  26.     nid.hIcon = Form1.Icon.Handle
  27.     nid.szTip = TipString + Chr(0)
  28. End Sub
  29. Private Sub Form_Load()
  30.     Dim nid As NotifyIconData
  31.     InitNID nid, "My First Tray Icon"           ' Initialize the nid
  32.     Shell_NotifyIcon Nim_Add, nid               ' Add icon to the Tray
  33.     ' Now subclass the form so that we receive Tray notifications
  34.     OldWndProc = GetWindowLong(hWnd, Gwl_WndProc)
  35.     SetWindowLong hWnd, Gwl_WndProc, AddressOf FormWindowProc
  36. End Sub
  37. Private Sub Form_Unload(Cancel As Integer)
  38.     Dim nid As NotifyIconData
  39.     InitNID nid, ""                             ' Initialize the nid
  40.     Shell_NotifyIcon Nim_Delete, nid            ' Remove icon from the Tray
  41.     ' Unhook the subclassing mechanism from this form
  42.     SetWindowLong hWnd, Gwl_WndProc, OldWndProc
  43. End Sub
  44.