Solved

How to hide an icon from the systray.

Posted on 2007-11-14
3
299 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
consolidate or create a new vba code for performing tasks 5 66
Excel - Save a copy of work book 13 84
message box in access 4 46
Protecting vb6 & .Net code Obfuscation 18 121
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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

770 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