Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 273345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:26:37+00:00 2026-05-12T00:26:37+00:00

this line of the code makes the form see-through User32Wrappers.SetLayeredWindowAttributes(Me.Handle, 0, _ 255 *

  • 0

this line of the code makes the form see-through “User32Wrappers.SetLayeredWindowAttributes(Me.Handle, 0, _
255 * 0.4, User32Wrappers.LWA.Alpha)”

if i adjust 0.4 to 0.6 it will become less see-through.

i would like to know if i can control this variable through a trackbar and how!

Public Class Form1

    Private _InitialStyle As Integer


    Private Sub Form_Load(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) _
        Handles MyBase.Load

        Form2.Show()



        ' Grab the Extended Style information

        ' for this window and store it.

        _InitialStyle = User32Wrappers.GetWindowLong(Me.Handle, User32Wrappers.GWL.ExStyle)

        ' Set this window to Transparent

        ' (to the mouse that is!)

        SetFormToTransparent()

        ' Just for giggles, set this window

        ' to stay on top of all others so we

        ' can see what's happening.

        Me.TopMost = True
    End Sub

    Private Sub SetFormToTransparent()
        ' This creates a new Extended Style

        ' for our window, which takes effect

        ' immediately upon being set, that

        ' combines the initial style of our window

        ' (saved in Form.Load) and adds the ability

        ' to be Transparent to the mouse.

        ' Both Layered and Transparent must be

        ' turned on for this to work AND have

        '  the window render properly!

        User32Wrappers.SetWindowLong(Me.Handle, User32Wrappers.GWL.ExStyle, _
            _InitialStyle Or User32Wrappers.WS_EX.Layered Or User32Wrappers.WS_EX.Transparent)

        ' Don't forget to set the Alpha

        ' for the window or else you won't be able

        ' to see the window! Possible values

        ' are 0 (visibly transparent)

        ' to 255 (visibly opaque). I'll set

        ' it to 20% visible here for show.

        ' The second parameter is 0, because

        ' we're not using a ColorKey!

        User32Wrappers.SetLayeredWindowAttributes(Me.Handle, 0, _
                           255 * 0.4, User32Wrappers.LWA.Alpha)
    End Sub

    Private Sub SetFormToOpaque()
        ' Turn off the Transparent Extended Style.

        User32Wrappers.SetWindowLong(Me.Handle, User32Wrappers.GWL.ExStyle, _
                _InitialStyle Or User32Wrappers.WS_EX.Layered)

        ' Set the Alpha back to 100% opaque.

        User32Wrappers.SetLayeredWindowAttributes(Me.Handle, _
                           0, 255, User32Wrappers.LWA.Alpha)
    End Sub

    Public Class User32Wrappers

        Public Enum GWL As Integer
            ExStyle = -20
        End Enum

        Public Enum WS_EX As Integer
            Transparent = &H20
            Layered = &H80000
        End Enum

        Public Enum LWA As Integer
            ColorKey = &H1
            Alpha = &H2
        End Enum

        <DllImport("user32.dll", EntryPoint:="GetWindowLong")> _
        Public Shared Function GetWindowLong( _
            ByVal hWnd As IntPtr, _
            ByVal nIndex As GWL _
                ) As Integer
        End Function

        <DllImport("user32.dll", EntryPoint:="SetWindowLong")> _
        Public Shared Function SetWindowLong( _
            ByVal hWnd As IntPtr, _
            ByVal nIndex As GWL, _
            ByVal dwNewLong As WS_EX _
                ) As Integer
        End Function

        <DllImport("user32.dll", _
          EntryPoint:="SetLayeredWindowAttributes")> _
        Public Shared Function SetLayeredWindowAttributes( _
            ByVal hWnd As IntPtr, _
            ByVal crKey As Integer, _
            ByVal alpha As Byte, _
            ByVal dwFlags As LWA _
                ) As Boolean
        End Function
    End Class

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        End
    End Sub
End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T00:26:37+00:00Added an answer on May 12, 2026 at 12:26 am

    You’ve done most of the work here! Just add a TrackBar to your form, set the Minimum to 1, Maximum to 100, and add the following code to your Form:

    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        SetOpacity(TrackBar1.Value / 100)
    End Sub
    
    Private Sub SetOpacity(ByVal value As Single)
    
        ' Turn off the Transparent Extended Style.
        User32Wrappers.SetWindowLong(Me.Handle, User32Wrappers.GWL.ExStyle, _
                _InitialStyle Or User32Wrappers.WS_EX.Layered)
    
        ' Set the Alpha.
        User32Wrappers.SetLayeredWindowAttributes(Me.Handle, _
                           0, 255 * value, User32Wrappers.LWA.Alpha)
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This line of code ((Matches)Container.DataItem).MatchID works in C# but in VB.NET, when used in
Given this line of code in C: printf(%3.0f\t%6.1f\n, fahr, ( (5.0/9.0) * (fahr-32) )
Got this line of code here but its not working. private void Button_Click(object sender,
I have this line of code for page load: if ($(input).is(':checked')) { and it
Ran across this line of code: FormsAuth = formsAuth ?? new FormsAuthenticationWrapper(); What do
I have a this line of code: var predicate = Expression.Lambda<Func<TEntityType, bool>>(body, param); where
I found this line of code and I'm trying to comprehend what it's doing.
I found this line of code when upgrading a C++ Builder project to RAD
I've got this line of code: $xml_output .= \t<Event= . $x . >\n; And
In my form's class, I've added a method to fade it out. This makes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.