Hallo ChickenWing und Maas,
vielen Dank für die schnelle Antwort und Vorschläge. Hab alles geändert bzw. so und so (mit ohne Handles) versucht. Aber keine Reaktion. Er mag einfach nicht.
Jetzt sieht's so aus:
Imports System
Imports System.Windows.Forms
Imports System.Drawing
Public Class Service1
Public WithEvents TrayIcon As New NotifyIcon
Private ServiceTimer As System.Timers.Timer
Protected Overrides Sub OnStart(ByVal args() As String)
EventLog.WriteEntry("Der IconTray-Testdienst wurde gestartet.", _
EventLogEntryType.Information)
ServiceTimer = New System.Timers.Timer()
ServiceTimer.Interval = 100000
ServiceTimer.Enabled = True
AddHandler ServiceTimer.Elapsed, AddressOf OnTimerEvent
' NotifyIcon selbst erzeugen
TrayIcon = New NotifyIcon()
TrayIcon.Icon = New Icon("c:\test.ico")
TrayIcon.Text = "Klick mich!!!!"
TrayIcon.Visible = True
AddHandler TrayIcon.MouseDown, AddressOf NotifyIconMouseDown
AddHandler TrayIcon.MouseClick, AddressOf NotifyIconMouseClick
AddHandler TrayIcon.Click, AddressOf TrayIcon_Click
End Sub
Public Sub TrayIcon_Click(ByVal sender As Object, ByVal e As _
System.EventArgs) Handles TrayIcon.Click
MsgBox("Klick")
End Sub
Private Shared Sub NotifyIconMouseClick(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles TrayIcon.MouseClick
MsgBox("Mausklick", MsgBoxStyle.SystemModal)
End Sub
Private Shared Sub NotifyIconMouseDown(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles TrayIcon.MouseDown
If e.Button = MouseButtons.Right Then
MsgBox("rechte Maustaste", MsgBoxStyle.SystemModal)
ElseIf e.Button = MouseButtons.Left Then
MsgBox("linke Maustaste", MsgBoxStyle.SystemModal)
End If
End Sub
Protected Sub OnTimerEvent(ByVal source As Object, ByVal e As _
System.Timers.ElapsedEventArgs)
EventLog.WriteEntry("Eintrag des IconTray-Testdienstes.", _
EventLogEntryType.Information)
End Sub
Protected Overrides Sub OnStop()
EventLog.WriteEntry("Der IconTray-Testdienst wurde beendet.", _
EventLogEntryType.Information)
TrayIcon.Visible = False
End Sub
End Class Vielleicht hat ja noch jemand eine Idee. Das ist bestimmt irgendwas 'Kleines', aber ich seh keinen Wald sondern nur Bäume.
Es grüßt,
Der Eydeet mit 9 Gehirnen
________________________________________________________
K?pt'n Blauber: "Ein B?r braucht seine Geheimnisse." |