Windows Blend Effect (Transparency) in VB.NET

Submitted by: 
Visitors have accessed this post 416 times.

This tutorial will teach you how to create a blend effect in your windows form or a transparency/opacity of the form using vb.net. This will use "user32" library of our computer system so that it will take effect.

Now, let's start this tutorial!

1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application.

2. Create only a Form in your project. Insert also a Timer on it. It's up to you to put any other controls on it.

3. Now, we will do the coding.

We will first declare the function named AnimateWindow to use the user32 library with the following values of it.

  1. Private Const AW_BLEND = &H80000
  2. Private Declare Function AnimateWindow Lib "user32" (ByVal hwnd As Int32, ByVal dwTime As Int32, ByVal dwFlags As Int32) As Boolean
  3. Dim winHide As Integer = &H10000
  4. Dim winBlend As Integer = &H80000

We will first to code for ticking our Timer, we will have the form's opacity of it to activate the transparency of the Form.

  1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  2. Me.Opacity = Me.Opacity + 0.1
  3. If Me.Opacity = 1 Then
  4. Timer1.Enabled = False
  5. End If
  6. End Sub

Then, we'll trigger to load the form by its transparency using the timer code.

  1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2. Timer1.Enabled = True
  3. Me.Opacity = 0.1
  4. End Sub

To have the blended effect, we will put this code on the closing of Form. We will also call the function that we have declared above.

  1. Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs)
  2. Try
  3. AnimateWindow(Me.Handle.ToInt32, CInt(500), winHide Or winBlend)
  4. Catch ex As Exception
  5.  
  6. End Try
  7. End Sub

Try it! :)

For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.

Best Regards,

Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]

Add and Follow me on Facebook: https://www.facebook.com/donzzsky

Visit and like my page on Facebook at: https://www.facebook.com/BermzISware


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.