Valhalla Legends Forums Archive | Visual Basic Programming | Tray CallBack

AuthorMessageTime
Networks
[code]
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)
[/code]

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.
February 22, 2005, 1:59 AM
CrAz3D
This is what CrAz3D does:
[code]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[/code]

this is the rest of my code stuffs
[code]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[/code]
February 22, 2005, 2:22 AM
Networks
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:
[code]
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
[/code]
February 22, 2005, 6:18 PM
CrAz3D
Is your mousing moving? ;)

That is just seems gay.  That event isn't firing at all?
February 22, 2005, 11:27 PM
Stealth
Does this sound relevant?
February 23, 2005, 12:56 AM
Networks
Yoni stated:
[code]
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)
[/code]

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."
February 23, 2005, 2:33 PM
soLo.abUse
[quote author=Networks link=topic=10664.msg101175#msg101175 date=1109169225]
Yoni stated:
[code]
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)
[/code]

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]

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.

[code]
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
[/code]
February 23, 2005, 7:42 PM
R.a.B.B.i.T
(I like the edit messages in the posts on that thread :)
February 24, 2005, 9:38 PM

Search