I have a system tray app which gets the status of a windows service,
and displays the appropriate icon for the status of the service in the
systray.
the problem I am having is the icon disapears under certain conditions,
but the exe is still listed in the processes leading me to believe the
app is still running.
It fires up perfectly on boot, however if the user logs off, and then
logs back in (not reboot), or if the system goes to standby, or
hibernate, the icon is lost (hidden) from the system tray.
the app is loaded from the HKCU portion of the registry.
Like I say, it refreshes fine based on the status of the service, but
it disapears based on the criteria above.
ideas?
I have gone overboard in my code to try and force it to never lose the
icon, but can not pinpoint my error.
<snip>
Imports System.Diagnost ics
Imports System.Text
Imports System.Xml
Imports System.IO
Public Module MNotify
Private WithEvents mobNotifyIcon As NotifyIcon
Private WithEvents mobContextMenu As ContextMenu
Private WithEvents mobTimer As Timers.Timer
Private WithEvents mobXDaysTimer As Timers.Timer
Private mobServiceContr oller As
System.ServiceP rocess.ServiceC ontroller
Public lastfilewritten As String
Public logDirectory As String
Public lastfile As String
Public intVariance As Integer
Public lastfiledatewri tten As String
Public Sub Main()
Try
'//SET UP CONECTION TO SERVICE.
mobServiceContr oller = New
System.ServiceP rocess.ServiceC ontroller("MySe rvice")
'//KEEP NOTIFY ICON HIDDEN UNTIL ICON AND MENU IS SET.
mobNotifyIcon = New NotifyIcon
mobNotifyIcon.V isible = False
mobContextMenu = New ContextMenu
CreateMenu()
mobNotifyIcon.C ontextMenu = mobContextMenu
SetUpTimer()
SetUpXDaysTimer ()
mobNotifyIcon.V isible = True
Application.Run ()
Catch obEx As Exception
MsgBox("error starting systray app:" &
obEx.Message.To String, MsgBoxStyle.Cri tical)
End
End Try
End Sub
Private Sub SetUpTimer()
Try
mobTimer = New Timers.Timer
With mobTimer
..AutoReset = True
..Interval = 5000
'.Interval = 60000
..Start()
End With
Catch obEx As Exception
mobNotifyIcon.I con = New Icon("mbNotifyO ff.ico")
MsgBox("systray : can not setup timer: Service not
functioning..." )
End Try
End Sub
Private Sub SetUpXDaysTimer ()
Try
mobXDaysTimer = New Timers.Timer
With mobXDaysTimer
..AutoReset = True
'show every 4 hours, or 6 times a day (1000 * 60 * 60 *
4)
..Interval = 14400000
'.Interval = 30000
..Start()
End With
Catch obEx As Exception
MsgBox("systray : can not set up SetupXDaysTimer ")
End Try
End Sub
Private Sub CreateMenu()
Try
mobContextMenu. MenuItems.Add(N ew MenuItem("Launc h Utility",
New EventHandler(Ad dressOf LaunchUtility)) )
Catch obEx As Exception
MsgBox("systray : can not add menu")
End Try
End Sub
Private Sub GetServiceStatu s()
Try
'//REFRESH PROPERTIES BEFORE READING.
mobServiceContr oller.Refresh()
'//REFLECT STATUS IN THE CONTEXT MENU.
Select Case mobServiceContr oller.Status()
Case ServiceProcess. ServiceControll erStatus.Paused
mobNotifyIcon.I con = New Icon("mbNotifyP aused.ico")
mobNotifyIcon.T ext = "Scheduler - Paused..."
Case ServiceProcess. ServiceControll erStatus.Runnin g
mobNotifyIcon.I con = New Icon("mbNotifyO n.ico")
mobNotifyIcon.T ext = "Scheduler - Running..."
Case ServiceProcess. ServiceControll erStatus.Stoppe d
mobNotifyIcon.I con = New Icon("mbNotifyO ff.ico")
mobNotifyIcon.T ext = "Scheduler - Stopped..."
Case _
ServiceProcess. ServiceControll erStatus.Contin uePending, _
ServiceProcess. ServiceControll erStatus.PauseP ending, _
ServiceProcess. ServiceControll erStatus.StartP ending, _
ServiceProcess. ServiceControll erStatus.StopPe nding
mobNotifyIcon.I con = New Icon("mbNotifyP aused.ico")
mobNotifyIcon.T ext = "Scheduler - Pending..."
Case Else
mobNotifyIcon.I con = New Icon("mbNotifyO ff.ico")
MsgBox("Service not functioning..." )
mobNotifyIcon.T ext = "Error..."
End Select
mobNotifyIcon.V isible = True
Catch obEx As Exception
mobNotifyIcon.I con = New Icon("mbNotifyO ff.ico")
MsgBox("Service not functioning..." )
mobNotifyIcon.T ext = "Error..."
End Try
End Sub
Public Sub mobTimer_Elapse d(ByVal sender As Object, ByVal e As
System.Timers.E lapsedEventArgs ) Handles mobTimer.Elapse d
Try
GetServiceStatu s()
Catch obEx As Exception
'MsgBox("systra y: Can not get service status:" &
obEx.Message)
mobNotifyIcon.I con = New Icon("mbNotifyO ff.ico")
MsgBox("Service not functioning..." )
End Try
End Sub
Public Sub mobXDaysTimer_E lapsed(ByVal sender As Object, ByVal e As
System.Timers.E lapsedEventArgs ) Handles mobXDaysTimer.E lapsed
Try
ShowPop()
Catch obEx As Exception
End Try
End Sub
Private Sub ExitController( ByVal sender As Object, ByVal e As
EventArgs)
Try
mobTimer.Stop()
mobTimer.Dispos e()
mobNotifyIcon.V isible = False
mobNotifyIcon.D ispose()
mobServiceContr oller.Dispose()
Application.Exi t()
Catch obEx As Exception
End Try
End Sub
</snip> 0 1833 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Action |
last post by:
I can add a systray icon in normal windows application...
but when i do it in windows service, the systray icon just don't show up
is that because i don't have any "component" to contain the systray icon?
please give direction...
thx
|
by: mario |
last post by:
How to put an application in systray with F1 or any shortcut button?
|
by: Christoph Engelhardt |
last post by:
Hi newsgroup,
What I intend to do:
Write a small programm, that will add a new Button to every Window right
beside the Buttons for minimizing, maximizing and closing the window in
the window's titlebar. When this button is clicked the window itself
should be minimized to the systray
On my way there I found hardly any example via Google that suited my needs.
All I know about already is how to get all windows in VB.Net ( which
|
by: Erik Greene |
last post by:
I have written an application that contains a notifyicon
that will not dispose or end when Windows shutsdown.
I have seen other posts where people are experiencing the
same issue (see post in the csharp group), so I know that
this is an issues for others as well.
Does anyone know how to capture the Windows Exit/Shutdown
event?
|
by: kapcreations |
last post by:
I have a system tray app which gets the status of a windows service,
and displays the appropriate icon for the status of the service in the
systray.
the problem I am having is the icon disapears under certain conditions,
but the exe is still listed in the processes leading me to believe the
app is still running.
It fires up perfectly on boot, however if the user logs off, and then
logs back in (not reboot), or if the system goes to...
| |
by: Rotzooi |
last post by:
Hi,
I have a VB.NET Service application that's running fine under the Local
System account. But for configuration purposes I don't want to be dependent
on modifying the registry manually or using an seperate application (like I
do now).
I want to implement a system tray icon when someone logs on to the console.
I've tried several samples but I can't get the icon to the system tray. I
know there are some issues because the logged on...
|
by: Rob R. Ainscough |
last post by:
I have a VS 2005 Windows Service with a Installer project as part of my
solution. The Service installs fine but I can't seem to make either of
these work:
1. Have the service start after install
2. Have the service interact with the SysTray
In my ProjectInstaller.vb
Private Sub ServiceInstaller1_AfterInstall(ByVal sender As
|
by: Arvi |
last post by:
Hello,
Im quite new to c# windows application.
i need to write a application which stays on the systray and listens to the
SQL Table. (when the value is inserted as 0 - done thru Dataset and check it
every2 seconds?) i need to open another application thru command prompt and
pass the parametes of the DB and alert the user.
how this can be done?
|
by: Nick Craig-Wood |
last post by:
Does anyone have some hints / tips / experience with making a cross
platform systray icon? It should work on Windows, Gnome and KDE at
minimum.
I've seen the win32all code which is very similar to the C code I've
written before for Windows. It would be a small irritation to have to
integrate its event loop with whichever GUI framework I'm using for
the rest of it though.
I don't know how to make a systray under KDE/Gnome though, but...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |