PeteD
asked on
Hide icon in Sys Tray
I can add, modify and remove my own icon from the system stray, but I want to hide one belonging to another application.
Sybase - Adaptive server anywhere puts an SQL icon in the system tray when my app runs, allowing the user to right click on the icon and close the db connection, which could potentially corrupt my database. I need to identify the icon in question (by tool tip text or whatever) and hide it when my app runs. Any ideas?
Sybase - Adaptive server anywhere puts an SQL icon in the system tray when my app runs, allowing the user to right click on the icon and close the db connection, which could potentially corrupt my database. I need to identify the icon in question (by tool tip text or whatever) and hide it when my app runs. Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi! I've seen this question being asked by someone before. The best result was that all the icons were cleared, AS IF you did something like:
Press Ctrl+Alt+Del
Select 'Explorer' and Click onto 'End Task'
Click onto 'No' in order not to shut down.
Wait for some 10-20 seconds and they'll tell you that Explorer is not responding.
Then... click onto end task to remove all the icons : )
Sorry, I can't remember when+where the question was asked. Maybe the one who did that can help you, provided that he sees your question : )
That's it!
glass cookie : )
Press Ctrl+Alt+Del
Select 'Explorer' and Click onto 'End Task'
Click onto 'No' in order not to shut down.
Wait for some 10-20 seconds and they'll tell you that Explorer is not responding.
Then... click onto end task to remove all the icons : )
Sorry, I can't remember when+where the question was asked. Maybe the one who did that can help you, provided that he sees your question : )
That's it!
glass cookie : )
Heh, thanks glass_cookie, nice to have myself quoted.. :-)
You're welcome : ) By the way, that question was asked by kcnkk.
ASKER
Hmmm! Sorry Ive been a while, my internet connection at home has gone to pot! I'm gonna end this now though! Although my question has not really been answered I will award the points for the most useful suggestion.
I'm sure there MUST be a windows message I could intercept for when an icon is added to the sys tray, so that I can then do something about it.
One possible idea I've had is to simply place an app of mine in the system tray using something like e.g.
Dim CurrentPercent As Integer
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub Form_Load()
MsgBox ("Look at your clock in the System Tray")
Dim hWnd As Long, rctemp As RECT
hWnd = FindWindow("Shell_TrayWnd" , vbNullString)
hWnd = FindWindowEx(hWnd, 0, "TrayNotifyWnd", vbNullString)
'hWnd = FindWindowEx(hWnd, 0, "TrayClockWClass", vbNullString) 'uncomment
'this string and look progressbar only at clock
GetWindowRect hWnd, rctemp
With Me
.Top = 0
.Left = 0
.Height = Me.Height * (rctemp.Bottom - rctemp.Top) / Me.ScaleHeight
.Width = Me.Width * (rctemp.Right - rctemp.Left) / Me.ScaleWidth
End With
Timer.Enabled = True
SetParent Me.hWnd, hWnd
Picture1.Height = Me.ScaleHeight
Picture1.Width = Me.ScaleWidth
End Sub
Private Sub Form_DblClick()
Unload Me
End Sub
Private Sub Picture1_Click()
Unload Me
End Sub
Private Sub Form_Resize()
Picture1.Top = (Me.ScaleHeight - Picture1.Height) / 2
End Sub
Public Function UpdateProgress(pb As Control, ByVal Percent)
Dim Num$
If Not pb.AutoRedraw Then
pb.AutoRedraw = -1
End If
pb.Cls
pb.ScaleWidth = 100
pb.DrawMode = 10
Num$ = Format$(Percent, "###") + "%"
pb.CurrentX = 50 - pb.TextWidth(Num$) / 2
pb.CurrentY = (pb.ScaleHeight - pb.TextHeight(Num$)) / 2
pb.Print Num$
pb.Line (0, 0)-(Percent, pb.ScaleHeight), , BF
pb.Refresh
End Function
Private Sub Timer_Timer()
CurrentPercent = CurrentPercent + 1
If CurrentPercent < 101 Then
UpdateProgress Picture1, CurrentPercent
Else
Timer.Enabled = False
CurrentPercent = 0
End If
End Sub
But this is not an ideal solution, as customers may obviously wish to install other apps and use sys tray icons. Just a thought though! ;)
I'm sure there MUST be a windows message I could intercept for when an icon is added to the sys tray, so that I can then do something about it.
One possible idea I've had is to simply place an app of mine in the system tray using something like e.g.
Dim CurrentPercent As Integer
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub Form_Load()
MsgBox ("Look at your clock in the System Tray")
Dim hWnd As Long, rctemp As RECT
hWnd = FindWindow("Shell_TrayWnd"
hWnd = FindWindowEx(hWnd, 0, "TrayNotifyWnd", vbNullString)
'hWnd = FindWindowEx(hWnd, 0, "TrayClockWClass", vbNullString) 'uncomment
'this string and look progressbar only at clock
GetWindowRect hWnd, rctemp
With Me
.Top = 0
.Left = 0
.Height = Me.Height * (rctemp.Bottom - rctemp.Top) / Me.ScaleHeight
.Width = Me.Width * (rctemp.Right - rctemp.Left) / Me.ScaleWidth
End With
Timer.Enabled = True
SetParent Me.hWnd, hWnd
Picture1.Height = Me.ScaleHeight
Picture1.Width = Me.ScaleWidth
End Sub
Private Sub Form_DblClick()
Unload Me
End Sub
Private Sub Picture1_Click()
Unload Me
End Sub
Private Sub Form_Resize()
Picture1.Top = (Me.ScaleHeight - Picture1.Height) / 2
End Sub
Public Function UpdateProgress(pb As Control, ByVal Percent)
Dim Num$
If Not pb.AutoRedraw Then
pb.AutoRedraw = -1
End If
pb.Cls
pb.ScaleWidth = 100
pb.DrawMode = 10
Num$ = Format$(Percent, "###") + "%"
pb.CurrentX = 50 - pb.TextWidth(Num$) / 2
pb.CurrentY = (pb.ScaleHeight - pb.TextHeight(Num$)) / 2
pb.Print Num$
pb.Line (0, 0)-(Percent, pb.ScaleHeight), , BF
pb.Refresh
End Function
Private Sub Timer_Timer()
CurrentPercent = CurrentPercent + 1
If CurrentPercent < 101 Then
UpdateProgress Picture1, CurrentPercent
Else
Timer.Enabled = False
CurrentPercent = 0
End If
End Sub
But this is not an ideal solution, as customers may obviously wish to install other apps and use sys tray icons. Just a thought though! ;)
Even if you did remove it, it's quite possible that the program which put the icon there would notice it had gone and put it back.
I'm not saying there isn't a solution though, if someone has finally found it.