| |
VB.NET - FortgeschritteneCode: NotifyIcon mit ContectMenü und Balloon-Nachrichten | | | Autor: ap! | Datum: 27.02.05 14:02 |
| Hi. Ich habe lange nach einen Code gesucht, womit man nur ein Icon im Tray hat, wo ein Contextmenü UND Balloon-Popups mitgehen.
ich habe das jetzt gefunden. Ich denke das ich das hier posten sollte, da ich es nicht im Forum findne konnte, und ich es für wichtig finde. Und Sourcecode ist immergut !
Modul:
Imports System.Runtime.InteropServices
Public Class Balloon
<StructLayout(LayoutKind.Sequential)> _
Public Structure NOTIFYICONDATA
Public cbSize As Int32
Public hwnd As IntPtr
Public uID As Int32
Public uFlags As Int32
Public uCallbackMessage As IntPtr
Public hIcon As IntPtr
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> _
Public szTip As String
Public dwState As Int32
Public dwStateMask As Int32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
Public szInfo As String
Public uTimeout As Int32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=64)> _
Public szInfoTitle As String
Public dwInfoFlags As Int32
End Structure
Public Const NIF_MESSAGE As Int32 = &H1
Public Const NIF_ICON As Int32 = &H2
Public Const NIF_STATE As Int32 = &H8
Public Const NIF_INFO As Int32 = &H10
Public Const NIF_TIP As Int32 = &H4
Public Const NIM_ADD As Int32 = &H0
Public Const NIM_MODIFY As Int32 = &H1
Public Const NIM_DELETE As Int32 = &H2
Public Const NIM_SETVERSION As Int32 = &H4
Public Const NOTIFYICON_VERSION As Int32 = &H5
Public Const NIIF_ERROR As Int32 = &H3
Public Const NIIF_INFO As Int32 = &H1
Public Const NIIF_NONE As Int32 = &H0
Public Const NIM_SETFOCUS As Int32 = &H3
Public Enum BalloonMessageType
None = &H0
Info = &H1
[Error] = &H3
End Enum
Shared Sub NotifyBalloon(ByRef ntfyIcon As NotifyIcon, ByVal Title As _
String, ByVal Info As String, ByVal Type As BalloonMessageType, ByVal _
Timeout As Integer)
Dim t As Type = GetType(NotifyIcon)
Dim window As IntPtr = (CType(t.GetField("window", _
System.Reflection.BindingFlags.Instance Or _
System.Reflection.BindingFlags.NonPublic).GetValue(ntfyIcon), _
NativeWindow)).Handle
Dim id As Int32 = CType(t.GetField("id", _
System.Reflection.BindingFlags.Instance Or _
System.Reflection.BindingFlags.NonPublic).GetValue(ntfyIcon), Integer)
Dim uNIF As NOTIFYICONDATA
uNIF.cbSize = 0
uNIF.dwInfoFlags = 0
uNIF.dwState = 0
uNIF.dwStateMask = 0
uNIF.hIcon = IntPtr.Zero
uNIF.szTip = ""
uNIF.uCallbackMessage = New IntPtr(&H200)
uNIF.szInfoTitle = Title
uNIF.uTimeout = Timeout
uNIF.hwnd = window
uNIF.uID = id
uNIF.dwInfoFlags = CType(Type, Int32)
uNIF.uTimeout = NOTIFYICON_VERSION
uNIF.szInfo = Info
uNIF.uFlags = NIF_INFO
uNIF.cbSize = Marshal.SizeOf(uNIF)
Dim result As Int32 = Shell_NotifyIconA(NIM_MODIFY, uNIF)
End Sub
Private Declare Function Shell_NotifyIconA Lib "shell32" (ByVal dwMessage _
As Int32, ByRef pnid As NOTIFYICONDATA) As Int32
End Class Erstellt nun ein NotifyIcon (bei mir NotifyIcon1), optionell könnt ihr das jetzt mit einem Context Menü austatten. Der Aufruf für eine Balloon Box:
Balloon.NotifyBalloon(NotifyIcon1, "Überschrift", ""Text", DAUER) Hoffe das es euch hilft. Finde den Code super.
Gr??e
[AP!]
P.S.
Ich habe MSN, falls nochjemand MSN haben sollte, kann er mich ja addedn, dann k?nnen wir mal ?ber MSN labbern | |
Re: Code: NotifyIcon mit ContectMenü und Balloon-Nachrichten | | | Autor: Maywood | Datum: 27.02.05 14:36 |
| >> Danke für das Ändern vom Modul.
Bitte | |
Re: Code: NotifyIcon mit ContectMenü und Balloon-Nachrichten | | | Autor: Maywood | Datum: 27.02.05 18:11 |
| >> Ah, ich dachte schon, welches denn?
Ich war mal so frei. Der Code liest sich sonst ohne die Code Tags immer furchtbar.
>> Aber was weiss ich was ich alles angestellt habe...
Rein gar nichts | |
Re: Code: NotifyIcon mit ContectMenü und Balloon-Nachrichten | | | Autor: lars007 | Datum: 04.03.05 16:03 |
| Hallo Leute,
ich war zugegeben sehr Faul und habe die Class eins zu eins mal zum Testen kopiert...
Zum aufrufen nutze ich den folgenden Code...
Balloon.NotifyBalloon(NotifyIcon1, "Test", "Test", 1, 3000) Aber da passiert bei mir rein garnichts???
Muss ich was besonderes einstellen damit die BalloonBox aufgeht???
Thanks for Help...
Gruß
Lars | |
Re: Code: NotifyIcon mit ContectMenü und Balloon-Nachrichten | | | Autor: msdn | Datum: 04.04.05 20:11 |
| Da hatte sich wohl ein Fehler eingeschlichen.
So sollte es gehen:
Balloon.NotifyBalloon(Me.tray, "Active Status", "Text", _
Balloon.BalloonMessageType.Info, 2000) Mit freundlichen Gr??en
Peter | |
Re: Code: NotifyIcon mit ContectMenü und Balloon-Nachrichten | | | Autor: lars007 | Datum: 04.04.05 23:08 |
| Hallo Peter,
Me.tray wird leider nicht akzeptiert.
Danke und Gruß
Lars | |
Re: Code: NotifyIcon mit ContectMenü und Balloon-Nachrichten | | | Autor: msdn | Datum: 07.05.05 22:50 |
| Fehler geunden. Anstatt
Me.tray musst du deinen NotifyIcon1 schreiben. Bei mir hieß das Me.Tray (me für Form / tray für NotifyIcon1)
Hoffe es geht nun.
Mit freundlichen Gr??en
Peter | |
Re: Code: NotifyIcon mit ContectMenü und Balloon-Nachrichten | | | Autor: JTEGEL | Datum: 18.07.05 09:48 |
| Ich möchte gerne auch einen Hyperlink auf dem Balloon haben. Wie kann ich dass tun. Können Sie mich fielleicht helfen.
Danke | |
Re: Code: NotifyIcon mit ContectMenü und Balloon-Nachrichten | | | Autor: msdn | Datum: 18.07.05 12:51 |
| Oi, Das wird schwieriger. Soweit ich das sehe, hat der Balloon ja eine "Form" Eigenschaft. Somit kann man über Handels das ClickEvent ja villeicht mit einer Aufgabe verknüpfen.
Müsste soweit ich das jetzt nachvollziehe gehen.
Ansonsten-> Jemand anderes der auch Ahnung davon hat kann ja mal ne andere Möglichkeit posten.
Mit freundlichen Gr??en
Peter | |
Re: Code: NotifyIcon mit ContectMenü und Balloon-Nachrichten | | | Autor: hase23 | Datum: 05.08.05 21:09 |
| Danke, danach hab ich lange gesucht!!! | |
| Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
|
|
vb@rchiv CD Vol.6 vb@rchiv Vol.6
Geballtes Wissen aus mehr als 8 Jahren vb@rchiv!
Online-Update-Funktion Entwickler-Vollversionen u.v.m.Jetzt zugreifen Tipp des Monats Neu! sevPopUp 2.0
Dynamische Kontextmenüs!
Erstellen Sie mit nur wenigen Zeilen Code Kontextmenüs dynamisch zur Laufzeit. Vordefinierte Styles (XP, Office, OfficeXP, Vista oder Windows 8) erleichtern die Anpassung an die eigenen Anwendung... Weitere Infos
|