Solved

How to hide an icon from the systray.

Posted on 2007-11-14
3
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 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