Every user of Windows has seen the notifications on the Windows Taskbar. They are somehow not pleasant, but sometimes useful with the information they provide. If you want to make use of those in VB .Net, this article would show you how to do it.
Pretty much, the code adds an icon to the Taskbar. Then, once we click with the right button on it, we get a menu with “Start” and “End”. The “Start” option has another option “Ale”, which kindly shows us a messagebox with text “Opa” (which means “grandmother” in German FYI). If we click on the start we get the Welcome message with lorem ipsum text.
That’s all. How to build it? It is simple Windows Form Application with NotifyIcon and ContextMenuStrip:
It is important to set an icon for the NotifyIcon and to associate its “ContextMenuStrip” to ContextMenuStrip1, to make it work:
The rest of the code is here:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
Public Class Form1 Private Sub NotifyIcon1_MouseDown(sender As Object, e As MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick If e.Button = Windows.Forms.MouseButtons.Left Then Using my_form As New Form1() my_form.ShowDialog() End Using End If End Sub Private Sub StartToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles StartToolStripMenuItem.Click Dim str_lorem As String = "lorem ipsum taratatatatatata lorem ipsum" & _ vbCrLf & "more lore ipsum here!" & _ vbCrLf & "and even more lorem ipsum there." NotifyIcon1.ShowBalloonTip(1000, "Welcome ", str_lorem, ToolTipIcon.Info) End Sub Private Sub EndToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles EndToolStripMenuItem.Click Close() End Sub Private Sub AleToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AleToolStripMenuItem.Click MsgBox("Opa") End Sub End Class |
Here comes the code in GitHub! Enjoy it!