• Welcome to Valhalla Legends Archive.
 

Tray CallBack

Started by Networks, February 21, 2005, 07:59 PM

Previous topic - Next topic

Networks


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.

CrAz3D

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
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

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:

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)

CrAz3D

Is your mousing moving? ;)

That is just seems gay.  That event isn't firing at all?
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Stealth

- Stealth
Author of StealthBot

Networks

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."

soLo.abUse

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

R.a.B.B.i.T

(I like the edit messages in the posts on that thread :)