home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / taskvb4 / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-02-21  |  5.0 KB  |  153 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   3075
  5.    ClientLeft      =   2850
  6.    ClientTop       =   2070
  7.    ClientWidth     =   7290
  8.    Height          =   3510
  9.    Left            =   2790
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3075
  12.    ScaleWidth      =   7290
  13.    Top             =   1695
  14.    Width           =   7410
  15.    Begin VB.ListBox List1 
  16.       Height          =   2790
  17.       Left            =   4860
  18.       TabIndex        =   3
  19.       Top             =   120
  20.       Width           =   2355
  21.    End
  22.    Begin VB.CommandButton UpArrow 
  23.       Caption         =   "Place to hold the up arrow icon"
  24.       DragIcon        =   "Form1.frx":0000
  25.       Height          =   315
  26.       Left            =   900
  27.       TabIndex        =   1
  28.       Top             =   1320
  29.       Visible         =   0   'False
  30.       Width           =   3195
  31.    End
  32.    Begin VB.CommandButton DownArrow 
  33.       Caption         =   "Place to hold the down arrow icon"
  34.       DragIcon        =   "Form1.frx":030A
  35.       Height          =   315
  36.       Left            =   900
  37.       TabIndex        =   0
  38.       Top             =   1740
  39.       Visible         =   0   'False
  40.       Width           =   3195
  41.    End
  42.    Begin MsghookLib.Msghook Msghook1 
  43.       Left            =   240
  44.       Top             =   2400
  45.       _version        =   65536
  46.       _extentx        =   1085
  47.       _extenty        =   979
  48.       _stockprops     =   0
  49.    End
  50.    Begin VB.Label Label1 
  51.       Caption         =   $"Form1.frx":0614
  52.       Height          =   1095
  53.       Left            =   180
  54.       TabIndex        =   2
  55.       Top             =   120
  56.       Width           =   4575
  57.    End
  58.    Begin VB.Menu PopUp 
  59.       Caption         =   "PopUp"
  60.       Visible         =   0   'False
  61.       Begin VB.Menu MenuFunction 
  62.          Caption         =   "Function 1"
  63.          Index           =   0
  64.       End
  65.       Begin VB.Menu MenuFunction 
  66.          Caption         =   "Function 2"
  67.          Index           =   1
  68.       End
  69.       Begin VB.Menu MenuFunction 
  70.          Caption         =   "-"
  71.          Index           =   2
  72.       End
  73.       Begin VB.Menu MenuFunction 
  74.          Caption         =   "The last super function"
  75.          Index           =   3
  76.       End
  77.    End
  78. Attribute VB_Name = "Form1"
  79. Attribute VB_Creatable = False
  80. Attribute VB_Exposed = False
  81. Option Explicit
  82. Dim DownIcon As Integer
  83. Private Sub Form_Load()
  84. Dim ltemplong As Long
  85. 'Make sure the Explorer shell is running. If not, we can't use the taskbar
  86.     structBarData.lStructureSize = 36&
  87.     ltemplong = SHAppBarMessage(ABM_GETTASKBARPOS, structBarData)
  88.     If ltemplong <> 1 Then
  89.         Exit Sub
  90.     End If
  91. 'Set up the data structure for the Shell_NotifyIcon function
  92.     structNotify.lStructureSize = 88&
  93.     structNotify.hWnd = Me.hWnd
  94.     structNotify.lID = 0&
  95.     structNotify.lFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
  96.     structNotify.lCallBackMessage = UM_TASKBARMESSAGE
  97.     structNotify.hIcon = DownArrow.DragIcon
  98.     structNotify.sTip = "A very happy tooltip!" & Chr$(0)
  99.     ltemplong = Shell_NotifyIcon(NIM_ADD, structNotify)
  100.     DownIcon = True
  101. 'Setup the message blaster to call us when we
  102. 'get a message from the shell notify icon
  103.  Msghook1.HwndHook = Me.hWnd
  104.  Msghook1.Message(UM_TASKBARMESSAGE) = True
  105.       
  106. End Sub
  107. Private Sub Form_Unload(Cancel As Integer)
  108. Dim ltemplong As Long
  109. 'Remove icon from the taskbar
  110.     ltemplong = Shell_NotifyIcon(NIM_DELETE, structNotify)
  111. End Sub
  112. Private Sub MenuFunction_Click(Index As Integer)
  113.     If Index = 3 Then
  114.         MsgBox "I really like the super function too!"
  115.     End If
  116. End Sub
  117. Private Sub Msghook1_Message(ByVal msg As Long, ByVal wp As Long, ByVal lp As Long, result As Long)
  118.     List1.AddItem lp, 0
  119. Dim Okay As Long
  120. 'When we get the left mouse button going up message, we'll change the icon
  121.     If lp = 514 Then
  122.         If DownIcon = True Then
  123.             DownIcon = False
  124. 'Change icon to up arrow
  125.             structNotify.hIcon = UpArrow.DragIcon
  126.             structNotify.lFlags = NIF_ICON
  127.             Okay = Shell_NotifyIcon(NIM_MODIFY, structNotify)
  128. 'Change tip
  129.             structNotify.sTip = "A different happy tip!" & Chr$(0)
  130.             structNotify.lFlags = NIF_TIP
  131.             Okay = Shell_NotifyIcon(NIM_MODIFY, structNotify)
  132.         
  133.         Else
  134.         
  135.             DownIcon = True
  136. 'Change icon to down arrow
  137.             structNotify.hIcon = DownArrow.DragIcon
  138.             structNotify.lFlags = NIF_ICON
  139.             Okay = Shell_NotifyIcon(NIM_MODIFY, structNotify)
  140. 'Change tip
  141.             structNotify.sTip = "Back to the original tip!" & Chr$(0)
  142.             structNotify.lFlags = NIF_TIP
  143.             Okay = Shell_NotifyIcon(NIM_MODIFY, structNotify)
  144.         End If
  145.             
  146.     End If
  147. 'When we get a right click, we'll pop up a menu
  148.     If lp = 517 Then
  149.         PopupMenu PopUp
  150.     End If
  151.      
  152. End Sub
  153.