Solved

How to hide an icon from the systray.

Posted on 2007-11-14
3
295 Views
Last Modified: 2010-04-30
How can i hide/unhide an icon from systray using visual basic ? . It is possible to hide it from the systray using only his directory file ? this file is running only on systray with the path "c:\program files\nrk\nrk.exe"
If this is not possible is there any way to hide using any other method ? I have search a lot in the experts database but didnt find anything helpfull , hope you find my solution.
0
Comment
Question by:KingSencat
  • 2
3 Comments
 
LVL 8

Expert Comment

by:x86fix
Comment Utility
right click anywhere on the taskbar
choose properties
select hide icons
hit customize button
You can customize which items to show or hide always
0
 
LVL 17

Accepted Solution

by:
Shanmuga Sundaram earned 500 total points
Comment Utility
I got this code from somewhere in the net. This code can add icons in the systray and remove from tray. Better have a look at this. Hope this should solve your requirement.

Option Explicit

'Declare a user-defined variable
Private 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

'Declare constants for the API function.
Private Const NIM_ADD = &H0 ' Add an Icon
Private Const NIM_MODIFY = &H1 ' Edit/Change an Icon
Private Const NIM_DELETE = &H2 ' Remove Icon from Tray

'Declare constant for mouse event
Private Const WM_MOUSEMOVE = &H200

'Flags that indicate the members of NOTIFYICONDATA.
Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4

' Constants for the mouse clicks on the icon
' These allow you to add actions based on these
' events being raised.
'Left-click
Private Const WM_LBUTTONDBLCLK = &H203 'Double-click
Private Const WM_LBUTTONDOWN = &H201 'Button down

'Right-click
Private Const WM_RBUTTONDBLCLK = &H206 'Double-click
Private Const WM_RBUTTONDOWN = &H204 'Button down

'Declare the API function
Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean

'Declare a variable as the UDT NOTIFYICONDATA
Dim nid As NOTIFYICONDATA

Private Sub Form_Load()
     
   'Set the values for the NOTIFYICONDATA data type.
   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 ' <== You can change this to another icon
      .szTip = "SysTray ToolTip Goes Here" & vbNullChar ' <== You can change this also.
   End With
End Sub

Private Sub Form_Terminate()
   'Remove the icon from the taskbar when your program ends.
   Shell_NotifyIcon NIM_DELETE, nid
End Sub
Private Sub Command1_Click()
   Shell_NotifyIcon NIM_ADD, nid
End Sub

0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
Comment Utility
Also have a look at this thread
http://www.vbforums.com/showthread.php?t=464196
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now