Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement Special forms with VB.NET

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to achieve a special form of VB.NET, the article introduces in great detail, has a certain reference value, interested friends must read it!

VB.NET special form 1, easy to make transparent forms

VB.NET can easily make any transparent form: all we have to do is set the Opacity property to a value between 0.0 (completely transparent) and 1.0 (completely opaque) in the form's Properties window:

Dim frm As FrmTrans

= New FrmTrans ()

Frm.Opacity = 0.5

Frm.ShowDialog ()

VB.NET Special form 2, easy to make a form that is always at the top

In VB6, to make a form that is always at the top, we can only resort to the troublesome API function. However, in .NET, we simply set the TopMost property of the form to achieve the same effect! For example:

Dim frm As frmTopMost =

New frmTopMost ()

Frm.TopMost = True

Frm.Show ()

VB.NET Special form 3, easy to make invisible forms

If you want to write a hidden program that will not be discovered by others, making invisible forms is a necessary step. The visibility of a form is usually controlled by the Visible property. However, if you want the main form of a Windows application not to be visible when the application starts, you will find that the method of setting its Visible property to False is invalid, and the form will always display itself (this is because the lifetime of the startup form determines the lifetime of the application). Even so, we can easily implement invisible forms by simply setting the startup of the application as a module to separate the lifetime of the application from the lifetime of the form. In the following example, the form is automatically hidden for a specific period of time:

(1) in Visual Basic, right-click the project and select add Module to add the module to the Windows application.

(2) in the added module (or class), create a Main function that can be used as the project startup object:

Sub main ()

Dim F1 As New Form1 ()

F1.Visible = False

While Hour (Date.Now) < 15

If the current time is earlier than 15:00

Form auto-hide

Application.DoEvents ()

End While

F1.ShowDialog ()

End Sub

VB.NET special form 4, easy to write pallet program

As a special kind of form, the shortcut icon of the tray program is displayed in the system tray, and the form itself is hidden and invisible. Writing pallet programs in VB prior to .NET is very difficult, but the new NotifyIcon components provided by VB.NET make it easy for VB beginners to write such a program:

Create a new "Windows Application" and set the main form Opacity property to 0MagneFormBorderStyle property to None,ShowInTaskbar property to False, so that the form will be hidden after startup. Place a NotifyIcon component NotifyIcon1 and a ContextMenu (pop-up menu) component ContextMenu1 on the form, and add menu items to ContextMenu1 as needed.

Set the ICON property of NotifyIcon1, which is the shortcut icon that the application appears in the system tray; set the Text property of NotifyIcon1 to "VB.NET tray program", which is the text description that pops up when the mouse moves over the tray icon; set the ContextMenu property of NotifyIcon1 to ContextMenu1, that is, the pop-up menu when you right-click the shortcut icon is ContextMenu1. OK, press F5 to run!

The above is all the content of the article "how to implement Special forms 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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report