CCTV TECH
Nassau, Bahamas
Search this site Search Help
Default
Newest
Oldest
CCTV Forum News
Use our miniPSS tool to get
enhanced hotkeys in PSS.
miniPSS is an EXE wrapper
for PSS on Windows XP/7.
Visit the Forum Post
 
 
 
Tray Icon Module

Place your application in the system tray with an easy to use module.
Download VB6 project.
Form1.frm  - Example Form
 
      
Option Explicit

'// FORM

Private Sub Form_Load()
    mTray.Refresh Me                            ' TRAY ICON LOAD
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    mTray.Click Me, X                           ' TRAY ICON CLICK
End Sub

Private Sub Form_Resize()
    mTray.Resize Me                             ' TRAY ICON SHOW/HIDE
End Sub

Private Sub Form_Unload(Cancel As Integer)
    mTray.Destroy                               ' TRAY ICON CLOSE
End Sub

mTray.bas - Tray Icon Module

Option Explicit

Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean

Public Type NOTIFYICONDATA
    cbSize As Long
    hwnd As Long
    uId As Long
    uflags As Long
    uCallBackMessage As Long
    hIcon As Long
    szTip As String * 64
End Type

Public nid As NOTIFYICONDATA

Private FX As Single
Private FY As Single

Const NIM_ADD = &H0
Const NIM_MODIFY = &H1
Const NIM_DELETE = &H2
Const WM_MOUSEMOVE = &H200
Const NIF_MESSAGE = &H1
Const NIF_ICON = &H2
Const NIF_TIP = &H4
Const WM_LBUTTONDBLCLK = &H203
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const WM_RBUTTONDBLCLK = &H206
Const WM_RBUTTONDOWN = &H204
Const WM_RBUTTONUP = &H205

Public Sub Refresh(ByVal frm As Form)
    FX = frm.Width
    FY = frm.Height
    nid.cbSize = Len(nid)
    nid.hwnd = frm.hwnd
    nid.uId = vbNull
    nid.uflags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
    nid.uCallBackMessage = WM_MOUSEMOVE
    nid.hIcon = frm.Icon
    nid.szTip = App.Title & vbNullChar
    Call Shell_NotifyIcon(NIM_ADD, nid)
End Sub

Public Sub Click(ByVal frm As Form, ByVal X As Single)
    Dim Msg As Long
    Dim sFilter As String
    Msg = X / Screen.TwipsPerPixelX
    Select Case Msg
        Case WM_LBUTTONDOWN
            frm.WindowState = 0
            frm.Show
        Case WM_LBUTTONUP
        Case WM_LBUTTONDBLCLK
        Case WM_RBUTTONDOWN
        Case WM_RBUTTONUP
        Case WM_RBUTTONDBLCLK
    End Select
End Sub

Public Sub Resize(ByVal frm As Form)
    If frm.WindowState = 1 Then
        frm.Hide
        frm.WindowState = 0
    ElseIf frm.WindowState = 0 Then
        frm.Show
        frm.Width = FX
        frm.Height = FY
    End If
End Sub

Public Sub Destroy()
    Call Shell_NotifyIcon(NIM_DELETE, nid)
End Sub    

CCTV | DVR | Video Surveillance | CCTV Cameras | Remote Video | Tech Support | Software | Scripts | Articles | Burglar Alarms | Alarm Monitoring | Real Estate
Copyright © 2001/2012 BahamasSecurity.com
 
Website hosted in Nassau, The Bahamas