Solved

How to hide an icon from the systray.

Posted on 2007-11-14
3
297 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
ID: 20286636
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
ID: 20288011
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
ID: 20288013
Also have a look at this thread
http://www.vbforums.com/showthread.php?t=464196
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JSON Response and request in VB6 application 11 230
Excel - Save a copy of work book 13 82
Hide vba in gp 7 79
Added a column screws up code 5 47
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

948 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

19 Experts available now in Live!

Get 1:1 Help Now