oh ok then....
i am trying to make an activex control that is customizable but it lets you place an icon in the system tray that is linked to the main window....
this is all the coding i have at the moment
see if you can understand what is wrong.... thanks for this by the way
Option Explicit
Const MAX_TOOLTIP As Integer = 64
Const NIF_ICON = &H2
Const NIF_MESSAGE = &H1
Const NIF_TIP = &H4
Const NIM_ADD = &H0
Const NIM_DELETE = &H2
Const WM_MOUSEMOVE = &H200
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const WM_LBUTTONDBLCLK = &H203
Const WM_RBUTTONDOWN = &H204
Const WM_RBUTTONUP = &H205
Const WM_RBUTTONDBLCLK = &H206
Private Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * MAX_TOOLTIP
End Type
Private nfIconData As NOTIFYICONDATA
Private Declare Function Shell_NotifyIcon Lib "shell32.dll" _
Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData _
As NOTIFYICONDATA) As Long
Private Sub UserControl_Initialize()
'----------------------------------------------------------------------
' Add this application's icon to the system tray.
'
' Parm 1 = Handle of the window to receive notification messages
' associated with an icon in the taskbar status area.
' Parm 2 = Icon to display.
' Parm 3 = Handle of icon to display.
' Parm 4 = Tooltip displayed when cursor moves over system tray icon.
'
With nfIconData
.hwnd = UserControl.Parent.hwnd
.uID = UserControl.Parent.hwnd
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = UserControl.Parent.Icon.Handle
.szTip = "System Tray Example" & vbNullChar
.cbSize = Len(nfIconData)
End With
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
'----------------------------------------------------------------------
End Sub
Private Sub UserControl_Terminate()
Call Shell_NotifyIcon(NIM_DELETE, nfIconData) 'remove icon when done
End Sub
'Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Dim lMsg As Single
''
'' Determine the event that happened to the System Tray icon.
'' Left clicking the icon displays a message box.
'' Right clicking the icon creates an instance of an object from an
'' ActiveX Code component then invokes a method to display a message.
''
'lMsg = X / Screen.TwipsPerPixelX
'Select Case lMsg
' Case WM_LBUTTONUP 'Left button up
' Case WM_RBUTTONUP 'Right button up
' Case WM_MOUSEMOVE 'Mouse moved over icon
' Case WM_LBUTTONDOWN 'Left button down
' Case WM_LBUTTONDBLCLK 'Left button double click
' frmMain.WindowState = 0
' Case WM_RBUTTONDOWN 'Right button down
' Case WM_RBUTTONDBLCLK 'Right button double click
' Case Else
'End Select
'End Sub