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 make transparent form by VB.NET

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

Share

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

This article mainly introduces VB.NET how to make transparent forms, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Forms are the foundation of Windows applications. The new generation of development tool Visual Basic.Net provides more simple and rich methods for designing and making forms, and we can easily make a variety of special effects forms without resorting to complex and error-prone API functions.

1. VB.NET makes transparent forms, and VB.NET can easily make any transparent form: we just need to set the Opacity property to a value between 0.0 (completely transparent) and 1.0 (completely opaque) in the "Properties" window of the form:

Dim frm As FrmTrans = New FrmTrans () frm.Opacity = 0.5 frm.ShowDialog ()

2, easy to make the 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 headache 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 ()

3. VB.NET makes transparent forms. If you want to write a hidden program that will not be discovered by others, making transparent 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 to be transparent 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 simply set the startup of the application to a module, thus dividing the lifetime of the application from the lifetime of the form, and VB.NET makes transparent forms. 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)。 Within 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, the form automatically hides Application.DoEvents () End While f1.ShowDialog () End Sub

4. It is easy to write the tray program as a special form, its shortcut icon is displayed in the system tray, and the form itself hides the transparent form. It is very difficult to write a tray program in VB prior to .NET, but the new NotifyIcon components provided by VB.NET make it easy for beginners in VB to write such a program: create a new "Windows application", set the main form Opacity property to 0menFormBorderStyle 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, when you right-click the shortcut icon, the pop-up menu is ContextMenu1.OK, press F5 to run!

Thank you for reading this article carefully. I hope the article "how to make transparent forms in VB.NET" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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