Hola a todos.

Tengo un pequeño/gran problema con una clase que he hecho para colocar una aplicación en el Systray. En principio todo va bien y también funcionan los Balloons, pero el proyecto para el que lo hice (otros sí) NO me responde al evento MouseMove (o MouseDown) con lo que la aplicación se queda allí clavada.

Aquí pongo el código:

Código:
  1. '---------------------------------------------------------------------------------------
  2. ' Módulo    : mcSysTray
  3. ' Fecha     : 08/02/2010 08:57
  4. ' Autor     : FJGD
  5. ' Finalidad : Gestionar la colocación de un formulario en el SysTray de Windows
  6. '---------------------------------------------------------------------------------------
  7. ' Ejemplo de uso -----------------------------------------------------------------------
  8. ' (1) Declaración
  9. '    Private oSysTray As mcSysTray
  10. '---------------------------------------------------------------------------------------
  11. ' (2) En Form_Load
  12. '---------------------------------------------------------------------------------------
  13. '    Set oSysTray = New mcSysTray
  14. '    oSysTray.Inic Me.hWnd, Me.Icon, Me.Caption
  15. '    oSysTray.Place '(quitar si se usa en Resize)
  16. '---------------------------------------------------------------------------------------
  17. ' (2) En Form_UnLoad
  18. '---------------------------------------------------------------------------------------
  19. '    oSysTray.Remove
  20. '---------------------------------------------------------------------------------------
  21. ' (3) En Form_Resize
  22. '---------------------------------------------------------------------------------------
  23. '    If Me.WindowState = vbMinimized Then
  24. '      oSysTray.Place '(quitar si se usa en Load)
  25. '      Me.Hide
  26. '    End If
  27. '---------------------------------------------------------------------------------------
  28. ' (3) En Form_MouseMove
  29. '---------------------------------------------------------------------------------------
  30. '    Select Case IIf(Me.ScaleMode = vbPixels, X,  X / Screen.TwipsPerPixelX)
  31. '    Case WM_LBUTTONDBLCLK
  32. '      Me.WindowState = vbNormal
  33. '      Me.Show
  34. '    Case WM_RBUTTONUP
  35. '      PopupMenu mnuSysTray
  36. '    End Select
  37. '---------------------------------------------------------------------------------------
  38. ' (4) Menú contextual
  39. '---------------------------------------------------------------------------------------
  40. '    Private Sub mnuSysTrayRestaurar_Click()
  41. '      Me.WindowState = vbNormal
  42. '      Me.Show
  43. '    End Sub
  44. '    Private Sub mnuSysTraySalir_Click()
  45. '      Me.WindowState = vbNormal
  46. '      Me.Show
  47. '      Unload Me
  48. '    End Sub
  49. '---------------------------------------------------------------------------------------
  50. ' (5) Desplegar un Balloon sobre el Systray
  51. '---------------------------------------------------------------------------------------
  52. '    oSysTray.ShowBallon "Título", "Texto", usNIIF_INFO, 10000
  53. '---------------------------------------------------------------------------------------
  54. ' (6) Cambiar el icono (p.ej. en un timer)
  55. '---------------------------------------------------------------------------------------
  56. '    oSysTray.ChangeIcon(hNewIcon)
  57. '---------------------------------------------------------------------------------------
  58. Option Explicit
  59. '---------------------------------------------------------------------------------------
  60. 'Estructura NOTIFYICONDATA para usar con Shell_NotifyIcon
  61. Private Type NOTIFYICONDATA
  62.   cbSize As Long
  63.   hWnd As Long
  64.   uID As Long
  65.   uFlags As Long
  66.   uCallbackMessage As Long
  67.   hIcon As Long
  68.   szTip As String * 128
  69.   dwState As Long
  70.   dwStateMask As Long
  71.   szInfo As String * 256
  72.   uTimeout As Long
  73.   szInfoTitle As String * 64
  74.   dwInfoFlags As Long
  75. End Type
  76. '---------------------------------------------------------------------------------------
  77. 'Constantes
  78. Private Const NOTIFYICON_VERSION = 3
  79. Private Const NOTIFYICON_OLDVERSION = 0
  80.  
  81. Private Const NIM_ADD = &H0
  82. Private Const NIM_MODIFY = &H1
  83. Private Const NIM_DELETE = &H2
  84.  
  85. Private Const NIM_SETFOCUS = &H3
  86. Private Const NIM_SETVERSION = &H4
  87.  
  88. Private Const NIF_MESSAGE = &H1
  89. Private Const NIF_ICON = &H2
  90. Private Const NIF_TIP = &H4
  91.  
  92. Private Const NIF_STATE = &H8
  93. Private Const NIF_INFO = &H10
  94.  
  95. Private Const NIS_HIDDEN = &H1
  96. Private Const NIS_SHAREDICON = &H2
  97.  
  98. Private Const NIIF_NONE = &H0
  99. Private Const NIIF_WARNING = &H2
  100. Private Const NIIF_ERROR = &H3
  101. Private Const NIIF_INFO = &H1
  102. Private Const NIIF_GUID = &H4
  103. '---------------------------------------------------------------------------------------
  104. Public Enum usSysTrayBallonIcon
  105.   usNIIF_NONE = &H0
  106.   usNIIF_WARNING = &H2
  107.   usNIIF_ERROR = &H3
  108.   usNIIF_INFO = &H1
  109.   usNIIF_GUID = &H4
  110. End Enum
  111.  
  112. Public Enum usMouseEvent
  113.   usWM_MOUSEMOVE = &H200
  114.   usWM_LBUTTONDOWN = &H201
  115. End Enum
  116. '---------------------------------------------------------------------------------------
  117. ' Declaración Api
  118. Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" _
  119. (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
  120. '---------------------------------------------------------------------------------------
  121. 'Variables privada para guardar la estructura de Shell_NotifyIcon
  122. Private mSysTray As NOTIFYICONDATA
  123. '---------------------------------------------------------------------------------------
  124. 'Variables privadas para las propiedades de la clase
  125. Private mlhWnd As Long
  126. Private mlhIcon As Long
  127. Private msToolTipText As String
  128. Private msBalloonTitle As String
  129. Private msBalloonText As String
  130. Private mbPlaced As Boolean
  131. Private mlMouseEvent As Long
  132. '---------------------------------------------------------------------------------------
  133. Public Function Inic(lhWnd As Long, _
  134.                      lhIcon As Long, _
  135.                      Optional sToolTipText As String = "", _
  136.                      Optional lMouseEvent As usMouseEvent = usWM_MOUSEMOVE) _
  137.                      As Long
  138.   hWnd = lhWnd
  139.   hIcon = lhIcon
  140.   ToolTipText = sToolTipText
  141.   MouseEvent = lMouseEvent
  142.  
  143. End Function
  144.  
  145. Public Function Place() As Long
  146.  
  147.   mSysTray.cbSize = Len(mSysTray)
  148.   mSysTray.hWnd = hWnd
  149.   mSysTray.uID = vbNull
  150.   mSysTray.uFlags = NIF_ICON Or NIF_INFO Or NIF_MESSAGE Or NIF_TIP
  151.   mSysTray.uCallbackMessage = MouseEvent
  152.   mSysTray.hIcon = hIcon
  153.   mSysTray.szTip = ToolTipText & vbNullChar
  154.   mSysTray.dwState = 0
  155.   mSysTray.dwStateMask = 0
  156.    
  157.   'Notifica en el systray
  158.  If Placed Then
  159.     Place = Shell_NotifyIcon(NIM_MODIFY, mSysTray)
  160.   Else
  161.     Place = Shell_NotifyIcon(NIM_ADD, mSysTray)
  162.     mbPlaced = (Place <> 0)
  163.   End If
  164.  
  165. End Function
  166.  
  167.  
  168. Public Function Remove() As Long
  169.  
  170.   Remove = Shell_NotifyIcon(NIM_DELETE, mSysTray)
  171.   mbPlaced = (Remove = 0)
  172.  
  173. End Function
  174.  
  175. Public Function ShowBallon(Optional strBalloonTitle As String = "", _
  176.                            Optional strBalloonText As String = "", _
  177.                            Optional enuBalloonIcon As usSysTrayBallonIcon = usNIIF_INFO, _
  178.                            Optional lTimeOut As Long = 10000) As Long
  179.  
  180.   If Len(strBalloonTitle) > 0 Then
  181.     BalloonTitle = strBalloonTitle
  182.   End If
  183.   If Len(strBalloonText) > 0 Then
  184.     BalloonText = strBalloonText
  185.   End If
  186.   mSysTray.szInfoTitle = BalloonTitle & vbNullChar
  187.   mSysTray.szInfo = BalloonText & vbNullChar
  188.   mSysTray.dwInfoFlags = enuBalloonIcon
  189.   mSysTray.uTimeout = lTimeOut
  190.  
  191.   'Modifica el ícono con la información
  192.  ShowBallon = Shell_NotifyIcon(NIM_MODIFY, mSysTray)
  193.  
  194. End Function
  195.  
  196.  
  197. Public Function ChangeIcon(hNewIcon As Long) As Long
  198.  
  199.   mSysTray.hIcon = hNewIcon
  200.  
  201.   ChangeIcon = Shell_NotifyIcon(NIM_MODIFY, mSysTray)
  202.  
  203. End Function
  204.  
  205. Public Property Get hWnd() As Long
  206.   hWnd = mlhWnd
  207. End Property
  208.  
  209. Public Property Let hWnd(ByVal lhWnd As Long)
  210.   mlhWnd = lhWnd
  211. End Property
  212.  
  213. Public Property Get hIcon() As Long
  214.   hIcon = mlhIcon
  215. End Property
  216.  
  217. Public Property Let hIcon(ByVal lhIcon As Long)
  218.   mlhIcon = lhIcon
  219. End Property
  220.  
  221. Public Property Get ToolTipText() As String
  222.   ToolTipText = msToolTipText
  223. End Property
  224.  
  225. Public Property Let ToolTipText(ByVal sToolTipText As String)
  226.   msToolTipText = sToolTipText
  227. End Property
  228.  
  229. Public Property Get BalloonTitle() As String
  230.   BalloonTitle = msBalloonTitle
  231. End Property
  232.  
  233. Public Property Let BalloonTitle(ByVal sBalloonTitle As String)
  234.   msBalloonTitle = sBalloonTitle
  235. End Property
  236.  
  237. Public Property Get BalloonText() As String
  238.   BalloonText = msBalloonText
  239. End Property
  240.  
  241. Public Property Let BalloonText(ByVal sBalloonText As String)
  242.   msBalloonText = sBalloonText
  243. End Property
  244.  
  245. Public Property Get Placed() As Boolean
  246.   Placed = mbPlaced
  247. End Property
  248.  
  249. Public Property Get MouseEvent() As Long
  250.   MouseEvent = mlMouseEvent
  251. End Property
  252.  
  253. Public Property Let MouseEvent(ByVal lMouseEvent As Long)
  254.   mlMouseEvent = lMouseEvent
  255. End Property

¿Sabéis lo que puede ir mal? Si alguien sabe alguna razón por la que algunos proyectos no respondan a ese evento, me alegraría horrores.
Creo que se puede usar tal cual se ve en la ayuda del encabezamiento, ni siquiera hace falta crear el menú "Restaurar/Salir", con que responda al doble click ya estaría solucionado el tema.
Me bajé un OCX que funciona bien, pero de ser posible preferiría usar la clase. A ver si algún conocedor del tema me puede orientar.

Saludos .