Dim NID As NOTIFYICONDATA
With NID
.cbSize = Len(NID)
.hwnd = Form.hwnd
.uID = vbNull
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Icon
.szTip = Tip & vbNullChar
End With
Call Shell_NotifyIconA(NIM_ADD, NID)
I am able to send it to the tray w/ an icon but I am not able to call it back using mousemove for some reason. I have had this problem before but I don't know how to fix it. The callback function doesn't even call for some reason.
This is what CrAz3D does:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
On Error Resume Next
Dim Msg As Long
Dim sFilter As String
Msg = x / Screen.TwipsPerPixelX
Select Case Msg
Case WM_LBUTTONDOWN
Form1.Show
Form1.WindowState = 0
Case WM_LBUTTONUP
Case WM_LBUTTONDBLCLK
Case WM_RBUTTONDOWN
Case WM_RBUTTONUP
End Select
End Sub
this is the rest of my code stuffs
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 Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const WM_MOUSEMOVE = &H200
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_RBUTTONDBLCLK = &H206
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP = &H205
Public nid As NOTIFYICONDATA
Well I know how to do it but every now and again I can't call it back despite distinctly telling it to callback on mouse move.
I don't recieve this at all when I should:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
Is your mousing moving? ;)
That is just seems gay. That event isn't firing at all?
Does this (http://forum.valhallalegends.com/phpbbs/index.php?topic=334.0) sound relevant?
Yoni stated:
I suggest you drop this idea and use a custom message (like, WM_APP + 1 or similar) and subclass your form to capture it. (Ugh... VB subclassing, here we go again)
Does this mean I can just set the callback message (uCallbackMessage) to WM_APP + 1. I am not famaliar with being able to "subclass your form to capture it."
Quote from: Networks on February 23, 2005, 08:33 AM
Yoni stated:
I suggest you drop this idea and use a custom message (like, WM_APP + 1 or similar) and subclass your form to capture it. (Ugh... VB subclassing, here we go again)
Does this mean I can just set the callback message (uCallbackMessage) to WM_APP + 1. I am not famaliar with being able to "subclass your form to capture it."
Basically you change the window procedure. This can be achieved by using GetWindowLong() and SetWindowLong(). Use GetWindowLong() to get the address of the window procedure, store that away somewhere, then use SetWindowLong() to set the address of your window procedure designed to handle things differently. If you don't handle a message in your window procedure, you call the old window procedure.
OldWindowProc = GetWindowLong(Form.hWnd, GWL_WNDPROC)
If (SetWindowLong(Form.hWnd, GWL_WNDPROC, AddressOf MyWindowProc) = 0) Then
' Failure handler code here
End If
Function MyWindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case uMsg
Case WM_DESTROY:
Call MsgBox("The window is being destroyed!")
MyWindowProc = 0
Case Else:
MyWindowProc = CallWindowProc(OldWindowProc, hwnd, uMsg, wParam, lParam)
End Select
End Function
(I like the edit messages in the posts on that thread :)