Get the App
SLTechnology News&Howtos  ›  Development  › 

How to write pallet program with VB.NET

Shulou Source: shulou.com Published: 2022-06-02 08:50:30 10月02日 Update

This article mainly introduces how to use VB.NET to write pallet procedures, the article is very detailed, has a certain reference value, interested friends must read it!

The design and running environment of this program

(1) Windows 2000 Service

(2) Net Framework SDK official version

The programming process of VB.NET static pallet program

The so-called VB.NET static tray program refers to the tray program in which the icon in the system tray area is at rest after the program runs. On the contrary, the dynamic tray program refers to a kind of tray program that animates the icon in the system tray area. Let's take a look at how VB.NET implements the static tray program.

.net FrameWork SDK provides a component for writing pallet programs: the NotifyIcon component. The NotifyIcon component is a WinForm component located in the namespace "System.Windows.Forms". In the VB.NET program, just create an instance of the NotifyIcon component and assign a value to the "Icon" property of the NotifyIcon instance, and such a simple pallet program is completed. Here is the code (Form1.vb) for this simple pallet program:

Public Class Form1

Inherits System.Windows.Forms.Form

# Region Code generated by the Windows forms designer

Public Sub New ()

MyBase.New ()

'This call is required by the Windows forms designer.

InitializeComponent ()

'add any initialization after the InitializeComponent () call

End Sub

'form rewrite disposal to clean up the list of components.

Protected Overloads Overrides Sub Dispose

(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

Components.Dispose ()

End If

End If

MyBase.Dispose (disposing)

End Sub

'required for the Windows forms designer

Private components As System.ComponentModel.IContainer

'Note: the following procedures are required for the Windows forms designer

'you can modify this process using the Windows forms designer.

'don 't use the code editor to modify it.

Friend WithEvents NotifyIcon1 As System.Windows.Forms.NotifyIcon

'create an instance of NotifyIcon

Friend TrayIcon = New Icon ("Tray.ico")

'create an instance of Icon

Private Sub InitializeComponent ()

Me.components = New System.ComponentModel.Container ()

Me.NotifyIcon1 = New System.Windows.Forms.NotifyIcon

(Me.components)

Me.NotifyIcon1.Text = "NotifyIcon1"

Me.NotifyIcon1.Visible = True

'assign a value to the Icon attribute of the NotifyIcon instance to complete the simple pallet program

Me.NotifyIcon1.Icon = TrayIcon

Me.AutoScaleBaseSize = New System.Drawing.Size (6,14)

Me.ClientSize = New System.Drawing.Size (292,273)

Me.Name = "Form1"

Me.Text = "Form1"

End Sub

# End Region

End Class

'start the program

Module Module1

Sub Main ()

Application.Run (new Form1 ())

End sub

End Module

The above is all the contents of the article "how to write pallet programs in VB.NET". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Programs trays forms components designs examples code procedures static content icons properties articles systems runs values interests dynamics animation guys Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi macOS vpn Microsoft MySQL