I have been using the minimize to tray source i found upon this forum, i have ran into a problem and seeking your guys help once again. after having it minimized to tray for awhile it disappears but it's still running in my processes. Any ideas guys? Thanks in advance!
Code:
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
Global Const NIM_ADD = &H0
Global Const NIM_MODIFY = &H1
Global Const NIM_DELETE = &H2
Global Const WM_MOUSEMOVE = &H200
Global Const NIF_MESSAGE = &H1
Global Const NIF_ICON = &H2
Global Const NIF_TIP = &H4
Global Const WM_LBUTTONDBLCLK = &H203 'Double-click
Global Const WM_LBUTTONDOWN = &H201 'Button down
Global Const WM_LBUTTONUP = &H202 'Button up
'Right-click constants.
Global Const WM_RBUTTONDBLCLK = &H206 'Double-click
Global Const WM_RBUTTONDOWN = &H204 'Button down
Global Const WM_RBUTTONUP = &H205 'Button up
Declare Function Shell_NotifyIcon Lib "shell32" _
Alias "Shell_NotifyIconA" _
(ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Global nid As NOTIFYICONDATA
Sub AddToTray(TrayIcon, TrayText As String, TrayForm As Form)
'Set the individual values of the NOTIFYICONDATA data type.
nid.cbSize = Len(nid)
nid.hwnd = TrayForm.hwnd
nid.uId = vbNull
nid.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
nid.uCallBackMessage = WM_MOUSEMOVE
nid.hIcon = TrayIcon 'You can replace form1.icon with loadpicture=("icon's file name")
nid.szTip = TrayText & vbNullChar
'Call the Shell_NotifyIcon function to add the icon to the taskbar
'status area.
Shell_NotifyIcon NIM_ADD, nid
TrayForm.Hide
End Sub
Sub ModifyTray(TrayIcon, TrayText As String, TrayForm As Form)
nid.cbSize = Len(nid)
nid.hwnd = TrayForm.hwnd
nid.uId = vbNull
nid.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
nid.uCallBackMessage = WM_MOUSEMOVE
nid.hIcon = TrayIcon
nid.szTip = TrayText & vbNullChar
Shell_NotifyIcon NIM_MODIFY, nid
End Sub
Sub RemoveFromTray()
Shell_NotifyIcon NIM_DELETE, nid
End Sub
Function RespondToTray(x As Single)
RespondToTray = 0
Dim msg As Long
Dim sFilter As String
If frmMain.ScaleMode <> 3 Then msg = x / Screen.TwipsPerPixelX Else: msg = x
Select Case msg
Case WM_LBUTTONDOWN
Case WM_LBUTTONUP
Case WM_LBUTTONDBLCLK 'Left button double-clicked
RespondToTray = 1
Case WM_RBUTTONDOWN 'Right button pressed
RespondToTray = 2
Case WM_RBUTTONUP
Case WM_RBUTTONDBLCLK
End Select
End Function
Sub ShowFormAgain(TrayForm As Form)
Call RemoveFromTray
TrayForm.Show
End Sub
Why use that code? Why don't you use "System Tray Icon" in your Components folder. And then let's say we have a menu named mnuHide
Private Sub mnuHide_Click()
MySysTrayName.intray = true
MyForm.Hide
End Sub
And if you want it back
Private Sub MySysTrayName_Mousedown() '<-- One click and its back. You can have two clicks, or hover over.
MySysTrayName.intray = False
MyForm.Show
End Sub
And you can set the tooltip also for it, for like if you hover across it, it says "LoLBoT!! v1".
Maybe he doesn't want it to rely on another file? Visual Basic 6 relies on enough files as it is (mostly .ocx).
Maybe he doesn't care, just hasn't seen the alternative provided by QwertyMonster :p
I provided how he could do it, if he wants to do it that way, he can. I'm not saying "USE IT!!!! OR ELSE I EAT YOUR CHILDREN!!!11".
Yegg: Thank You
Why rely on another file when i can code it myself? Anywayz, back to the topic, does anyone have any idea why this would be occuring?
1) You should rely on another file because, as this topic is here, you can't code it yourself =p
2) You should rely on another file because if Microsoft releases a patch for a bug in it, you dont need to release a new bot.
3) This is general VB programming, not specifically Battle.net Bot Development.
if it takes some time for it to disappear, id say explorer is crashing..someone posted how to make your icon reappear if this happens, search for it.
Quote from: Joex86] link=topic=12615.msg125535#msg125535 date=1125056473]
1) You should rely on another file because, as this topic is here, you can't code it yourself =p
2) You should rely on another file because if Microsoft releases a patch for a bug in it, you dont need to release a new bot.
3) This is general VB programming, not specifically Battle.net Bot Development.
Reasons 1 and 2 are stupid. You are correct on 3.
While he can't initially code it himself, perhaps he will see what he is doing wrong.
Microsoft is unlikely to find a bug in MINIMIZING TO SYSTEM TRAY.
QuoteMicrosoft is unlikely to find a bug in MINIMIZING TO SYSTEM TRAY.
Pfft, it could apply to other things too, though. =p
Quote from: Warrior on August 26, 2005, 09:49 PMMicrosoft is unlikely to find a bug in MINIMIZING TO SYSTEM TRAY.
Agreed. They usually only find bugs after exploits for the bug have been in the wild for days or weeks. :) Exploiting any problem in the system tray code would be unlikely, since you'd generally have the ability to do much nastier things if you have the ability to manipulate the notification icons.