Public Class frmTaskbarOpacity
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
Declare Function GetWindowlong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Integer, ByVal nindex As Int32) As Int32
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As IntPtr, ByVal nIndex As Int32, ByVal dsNewLong As Int32) As Int32
Declare Function SetLayeredWindowAttributes Lib "user32" Alias "SetLayeredWindowAttributes" (ByVal hWnd As IntPtr, ByVal crKey As Integer, ByVal alpha As Byte, ByVal dwFlags As Byte) As Boolean
Dim hwnd As Integer = FindWindow("Shell_Traywnd", "")
Dim z As Byte
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
Dim opacIniz As Integer = GetWindowlong(hwnd, -20)
SetWindowLong(hwnd, -20, opacIniz Or &H80000)
SetLayeredWindowAttributes(hwnd, 0, 255 * (TrackBar1.Value / 100), &H2)
Label1.Text = "Opacità = " & TrackBar1.Value & " %"
End Sub
Private Sub tmrTaskbarGhost_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrTaskbar1.Tick
If z < 100 Then
z += 1
SetLayeredWindowAttributes(hwnd, 0, 255 * (z / 100), &H2)
End If
If z = 100 Then
tmrTaskbar1.Stop()
tmrTaskbar2.Start()
z = 100
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
tmrTaskbar1.Start()
End Sub
Private Sub tmrTaskbar2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrTaskbar2.Tick
If z <= 100 Then
z -= 1
SetLayeredWindowAttributes(hwnd, 0, 255 * (z / 100), &H2)
End If
If z = 0 Then
tmrTaskbar2.Stop()
tmrTaskbar1.Start()
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Windows.Forms.Cursor.Position.Y > (Screen.PrimaryScreen.WorkingArea.Height - 12) Then
SetLayeredWindowAttributes(hwnd, 0, 255, &H2)
Else
SetLayeredWindowAttributes(hwnd, 0, 0, &H2)
End If
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If Me.CheckBox2.CheckState = CheckState.Checked And CheckBox1.CheckState = CheckState.Checked Then
Me.CheckBox1.CheckState = CheckState.Unchecked
MessageBox.Show("Selezionare un' animazione alla volta!!!", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If Me.CheckBox1.CheckState = CheckState.Checked Then
Me.CheckBox1.Text = "Attivata"
tmrTaskbar1.Start()
TrackBar1.Enabled = False
Else
Me.CheckBox1.Text = "Disattivata"
tmrTaskbar1.Stop()
tmrTaskbar2.Stop()
z = 0
SetLayeredWindowAttributes(hwnd, 0, 255, &H2)
TrackBar1.Value = 100
Me.Label1.Text = "Opacità = 100 %"
TrackBar1.Enabled = True
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If Me.CheckBox1.CheckState = CheckState.Checked And CheckBox2.CheckState = CheckState.Checked Then
Me.CheckBox2.CheckState = CheckState.Unchecked
MessageBox.Show("Selezionare un' animazione alla volta!!!", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If Me.CheckBox1.CheckState = CheckState.Unchecked And CheckBox2.CheckState = CheckState.Checked Then
Me.CheckBox2.Text = "Attivata"
Timer1.Start()
TrackBar1.Enabled = False
Else
Me.CheckBox2.Text = "Disattivata"
Timer1.Stop()
SetLayeredWindowAttributes(hwnd, 0, 255, &H2)
TrackBar1.Enabled = True
End If
End Sub
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
Me.tmrTaskbar1.Interval = Me.NumericUpDown1.Value
Me.tmrTaskbar2.Interval = Me.NumericUpDown1.Value
End Sub
Private Sub InfoSuToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InfoSuToolStripMenuItem.Click
frmInfoSu.ShowDialog()
End Sub
Private Sub EsciToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EsciToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
SetLayeredWindowAttributes(hwnd, 0, 255, &H2)
End Sub
Private Sub MostraNascondiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MostraNascondiToolStripMenuItem.Click
If Me.Visible = True Then
Me.Visible = False
Else
Me.Visible = True
End If
End Sub
End Class