Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Taskbar Opacity - frmTaskbarOpacity.vb

frmTaskbarOpacity.vb

Caricato da: Progman-92
Scarica il programma completo

  1. Public Class frmTaskbarOpacity
  2.  
  3.     Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
  4.     Declare Function GetWindowlong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Integer, ByVal nindex As Int32) As Int32
  5.     Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As IntPtr, ByVal nIndex As Int32, ByVal dsNewLong As Int32) As Int32
  6.     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
  7.     Dim hwnd As Integer = FindWindow("Shell_Traywnd", "")
  8.     Dim z As Byte
  9.  
  10.     Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
  11.         Dim opacIniz As Integer = GetWindowlong(hwnd, -20)
  12.         SetWindowLong(hwnd, -20, opacIniz Or &H80000)
  13.         SetLayeredWindowAttributes(hwnd, 0, 255 * (TrackBar1.Value / 100), &H2)
  14.         Label1.Text = "Opacità = " & TrackBar1.Value & " %"
  15.     End Sub
  16.  
  17.     Private Sub tmrTaskbarGhost_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrTaskbar1.Tick
  18.         If z < 100 Then
  19.             z += 1
  20.             SetLayeredWindowAttributes(hwnd, 0, 255 * (z / 100), &H2)
  21.         End If
  22.         If z = 100 Then
  23.             tmrTaskbar1.Stop()
  24.             tmrTaskbar2.Start()
  25.             z = 100
  26.         End If
  27.     End Sub
  28.  
  29.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  30.         tmrTaskbar1.Start()
  31.     End Sub
  32.  
  33.     Private Sub tmrTaskbar2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrTaskbar2.Tick
  34.         If z <= 100 Then
  35.             z -= 1
  36.             SetLayeredWindowAttributes(hwnd, 0, 255 * (z / 100), &H2)
  37.         End If
  38.         If z = 0 Then
  39.             tmrTaskbar2.Stop()
  40.             tmrTaskbar1.Start()
  41.         End If
  42.     End Sub
  43.  
  44.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  45.         If Windows.Forms.Cursor.Position.Y > (Screen.PrimaryScreen.WorkingArea.Height - 12) Then
  46.             SetLayeredWindowAttributes(hwnd, 0, 255, &H2)
  47.         Else
  48.             SetLayeredWindowAttributes(hwnd, 0, 0, &H2)
  49.         End If
  50.     End Sub
  51.  
  52.     Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
  53.         If Me.CheckBox2.CheckState = CheckState.Checked And CheckBox1.CheckState = CheckState.Checked Then
  54.             Me.CheckBox1.CheckState = CheckState.Unchecked
  55.             MessageBox.Show("Selezionare un' animazione alla volta!!!", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error)
  56.         End If
  57.         If Me.CheckBox1.CheckState = CheckState.Checked Then
  58.             Me.CheckBox1.Text = "Attivata"
  59.             tmrTaskbar1.Start()
  60.             TrackBar1.Enabled = False
  61.         Else
  62.             Me.CheckBox1.Text = "Disattivata"
  63.             tmrTaskbar1.Stop()
  64.             tmrTaskbar2.Stop()
  65.             z = 0
  66.             SetLayeredWindowAttributes(hwnd, 0, 255, &H2)
  67.             TrackBar1.Value = 100
  68.             Me.Label1.Text = "Opacità = 100 %"
  69.             TrackBar1.Enabled = True
  70.         End If
  71.     End Sub
  72.  
  73.     Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
  74.         If Me.CheckBox1.CheckState = CheckState.Checked And CheckBox2.CheckState = CheckState.Checked Then
  75.             Me.CheckBox2.CheckState = CheckState.Unchecked
  76.             MessageBox.Show("Selezionare un' animazione alla volta!!!", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error)
  77.         End If
  78.  
  79.         If Me.CheckBox1.CheckState = CheckState.Unchecked And CheckBox2.CheckState = CheckState.Checked Then
  80.             Me.CheckBox2.Text = "Attivata"
  81.             Timer1.Start()
  82.             TrackBar1.Enabled = False
  83.         Else
  84.             Me.CheckBox2.Text = "Disattivata"
  85.             Timer1.Stop()
  86.             SetLayeredWindowAttributes(hwnd, 0, 255, &H2)
  87.             TrackBar1.Enabled = True
  88.         End If
  89.     End Sub
  90.  
  91.     Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
  92.         Me.tmrTaskbar1.Interval = Me.NumericUpDown1.Value
  93.         Me.tmrTaskbar2.Interval = Me.NumericUpDown1.Value
  94.     End Sub
  95.  
  96.     Private Sub InfoSuToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InfoSuToolStripMenuItem.Click
  97.         frmInfoSu.ShowDialog()
  98.     End Sub
  99.  
  100.     Private Sub EsciToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EsciToolStripMenuItem.Click
  101.         Me.Close()
  102.     End Sub
  103.  
  104.     Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
  105.         SetLayeredWindowAttributes(hwnd, 0, 255, &H2)
  106.     End Sub
  107.  
  108.     Private Sub MostraNascondiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MostraNascondiToolStripMenuItem.Click
  109.         If Me.Visible = True Then
  110.             Me.Visible = False
  111.         Else
  112.             Me.Visible = True
  113.         End If
  114.     End Sub
  115. End Class