Author | Message | Time |
---|---|---|
Stealth | Any idea why the Form_MouseMove(Button As Integer, Shift As Integer, X As Single, y As Single) subroutine code isn't firing when the mouse is moved over the form? The code needs to run to retrieve my program from the system tray when it's minimized.. If you've ever used StealthBot v1.1.2 you'll know that the code used to work fine. The latest build uses the same code as 1.1.2 under Form_MouseMove, but the code doesn't execute when the mouse is moved. I ran the source in step-by-step mode (f8) to make sure, and the code just isn't running. Here is the mousemove code. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, y As Single) 'receives the callbacks from the System Tray icon. Dim Result As Long Dim msg As Long If Me.ScaleMode = vbPixels Then msg = X Else msg = X / Screen.TwipsPerPixelX End If Select Case msg Case WM_LBUTTONDBLCLK '515 restore form window Me.WindowState = vbNormal Result = SetForegroundWindow(Me.HWnd) Me.Show Case WM_RBUTTONUP '517 display popup menu Result = SetForegroundWindow(Me.HWnd) Me.PopupMenu mnuTray End Select End Sub Any help would be greatly appreciated. | December 23, 2002, 2:58 PM |
Grok | Value of msg? Try adding to your Select.. Case Else MsgBox "My code works, I'm just not setting msg!",vbExclamation | December 23, 2002, 5:02 PM |
Noodlez | he set message [quote] If Me.ScaleMode = vbPixels Then msg = X Else msg = X / Screen.TwipsPerPixelX End If [/quote] anyway, i didnt read through your code to see whats wrong, but heres the simple code i use [code] Dim bleh As Long bleh = x / Screen.TwipsPerPixelX Select Case bleh Case WM_LBUTTONDOWN: Me.PopupMenu mnuSystray End Select [/code] | December 23, 2002, 5:06 PM |
Stealth | Added a Case Else messagebox just to make sure, same thing. The code doesn't execute whatsoever. To be sure, I ran the program in "F8" mode, step by step, which lights up each line of code as it's executed. Once the form_load and form_resize procedures were done, I ran the mouse across it a number of times with no result. Minimizing it and clicking on the icon / moving over the icon also elicits no response. | December 23, 2002, 5:20 PM |
Grok | Point of my request was discovery. You say he set message but look at what he set it to? How do those compare to the cases in the select? There's a more fundamental issue here. "Does MouseMouse get fired on a minimized form?" It does not on my system, does it on yours? | December 23, 2002, 5:47 PM |
iago | No (on xp)... maybe a change in the way mousemoves are handled? | December 23, 2002, 6:27 PM |
Stealth | I've been playing around with the code, and it appears that if i replace the Form_Resize code in the latest version (where the tray icon doesn't work) with Form_Resize code from the last working version (1.1.2) the tray icon restores just fine. Therefore, the problem lies not in the Form_MouseMove code but in the Form_Resize code. Here it is. [code] Private Sub Form_Resize() On Error Resume Next If Me.WindowState = vbMinimized Then Me.Hide With nid .cbSize = Len(nid) .hwnd = Me.hwnd .uId = vbNull .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE .uCallBackMessage = WM_MOUSEMOVE .hIcon = Me.Icon .szTip = "StealthBot v1.1.2 Public Edition" & vbNullChar End With Shell_NotifyIcon NIM_ADD, nid Else Shell_NotifyIcon NIM_DELETE, nid rtbChat.Width = Me.ScaleWidth - lvChannel.Width rtbChat.Height = Me.ScaleHeight - cboSend.Height txtPre.Height = Me.ScaleHeight - rtbChat.Height txtPre.Top = rtbChat.Height txtPost.Height = Me.ScaleHeight - rtbChat.Height txtPost.Top = rtbChat.Height txtPost.Left = cboSend.Width + 700 lblCurrentChannel.Left = rtbChat.Width lblCurrentChannel.Width = lvChannel.Width lvChannel.Left = rtbChat.Width lvChannel.Height = Me.ScaleHeight - lblCurrentChannel.Height - cboSend.Height cboSend.Top = rtbChat.Height cboSend.Width = Me.ScaleWidth - txtPre.Width - txtPost.Width txtPost.Left = cboSend.Width + 700 cboSend.SetFocus End If End Sub [/code] >:( I have no idea what's wrong with this code. It took me quite awhile to get things lined up as I wanted them, can any of you Visual Basic pros see some mistake that could cause the system tray icon code not to work properly? Edited by Grok, added code tags. | December 24, 2002, 4:35 PM |
iago | put [code} and [/code} (with square brackets) around code.. looks nicer :D | December 24, 2002, 7:33 PM |
Stealth | Thank you Grok. :) Any ideas? I've been screwing around with it and it's unbelievably frustrating because even after making the form_resize code exactly the same as in the previous build it refuses to work. | December 24, 2002, 10:07 PM |
Grok | Well since it is not clear what nid is, I cannot begin to help you. | December 24, 2002, 10:28 PM |
Stealth | Apologies. Here's the module containing all the code referenced here. [quote]Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long 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 'constants required by Shell_NotifyIcon API call: Public Const NIM_ADD = &H0 Public Const NIM_MODIFY = &H1 Public Const NIM_DELETE = &H2 Public Const NIF_MESSAGE = &H1 Public Const NIF_ICON = &H2 Public Const NIF_TIP = &H4 Public Const WM_MOUSEMOVE = &H200 Public Const WM_LBUTTONDOWN = &H201 'Button down Public Const WM_LBUTTONUP = &H202 'Button up Public Const WM_LBUTTONDBLCLK = &H203 'Double-click Public Const WM_RBUTTONDOWN = &H204 'Button down Public Const WM_RBUTTONUP = &H205 'Button up Public Const WM_RBUTTONDBLCLK = &H206 'Double-click Public Declare Function SetForegroundWindow Lib "user32" _ (ByVal hwnd As Long) As Long Public nid As NOTIFYICONDATA [/quote] | December 25, 2002, 12:44 AM |
Yoni | [code].uCallBackMessage = WM_MOUSEMOVE [/code]This will send a WM_MOUSEMOVE msg to your form when the mouse moves over the tray icon. This is popular in VB because VB practically forwards WM_MOUSEMOVE to Form_MouseMove, after scaling wParam and lParam (which is why you had to divide by Screen.TwipsPerPixelX to get the actual message). However, I guess when the form is minimized/hidden, something eats the WM_MOUSEMOVE messages. 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) | December 27, 2002, 2:39 PM |
Stealth | Thank you Yoni. I've solved the problem by replacing the old WM_MouseMove structure with a subclass, and all is well. =) | December 30, 2002, 8:55 PM |