Use to make special effects forms easily

Source: Internet
Author: User
Tags current time

Forms are the basis for Windows applications. New generation of development tools Visual Basic.NET provides a more simple and rich way to design a form, and without resorting to complex and error-prone API functions, we can easily create multiple effects forms:

1, easy to make transparent forms

Vb. NET makes it easy to create a form that takes on transparency: all we have to do is set the Opacity property to a value between 0.0 (fully transparent) and 1.0 (completely opaque) in the form's Properties window:

Dim frm as Frmtrans = New Frmtrans ()

frm. Opacity = 0.5

frm. ShowDialog ()

2, easy to make always at the top of the form

In VB6, to make a form that is always at the top of the hierarchy we can only turn to a headache API function. However, in. NET, we simply set the form's topmost property to achieve the same effect! For example:

Dim frm as Frmtopmost = New frmtopmost ()

frm. topmost = True

frm. Show ()

3, easy to make invisible forms

If you want to write a hidden program that is not visible to others, making an invisible form is the first step you must make. The visibility of a form is usually controlled by the Visible property. However, if you want the main form of your Windows application to be invisible when the application starts, you will find that the method that sets its Visible property to False is invalid, and the form always displays itself (because the lifetime of the startup form determines the lifetime of the application). Even so, we can easily implement an invisible form by simply setting the application's startup to a module, separating 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) within a module (or class) that has been added, create a Main function that can be used as a project startup object:

Sub Main ()

Dim F1 as New Form1 ()

F1. Visible = False

While Hour ( < 15 ' If the current time is earlier than 15 o'clock, the form is automatically hidden

Application.doevents ()

End While

F1. ShowDialog ()

End Sub

4, easy to write tray program

The tray program acts as a special type of form whose shortcut icons appear in the system tray and the form itself is invisible. It is difficult to write a pallet program in a previous version of. NET VB, but the new NotifyIcon component provided by makes it easy for VB beginners to write a program like this:

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

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

Almost without writing code, a tray program is so easy to implement.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.