电脑技术学习

个性化你的Windows 7 Taskbar Thumbnail

dn001

  主要的代码就是这样, 下面是程序中所有的代码:

  Imports Microsoft.Win32

Public Class mainForm
    Dim path As String = "HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Explorer/Taskband"
    Private Sub textBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
        '这个函数的功能是判断按下的键是否为数字或者Backspace键
        If (e.KeyChar < "0" Or e.KeyChar > "9") Then
            e.Handled = True
            If Convert.ToInt32(e.KeyChar).Equals(8) Then
                e.Handled = False
            End If
        Else
            e.Handled = False
        End If
    End Sub 'KeyPress函数
    Private Sub txtBox_TextChanged(ByVal txtBox As TextBox, ByVal trackBar As TrackBar)
        'TextBox里的值发生变化后
        '如果值不为空
        If txtBox.Text <> "" Then
            '滑动条的值等于文本框内的数值
            Try
                trackBar.Value = txtBox.Text
                If trackBar.Value > 512 Then '如果滑动条的值超过512则抛出一个异常
                    Throw New Exception
                End If
            Catch ex As Exception
                trackBar.Value = 512
                txtBox.Text = "512"
            End Try
        End If
        '如果值为空
        If txtBox.Text = "" Then
            '滑动条的值置为0,文本框的值置为空
            trackBar.Value = 0
            txtBox.Text = ""
        End If
    End Sub 'TextChanged函数
    Private Sub trackBar_ValueChanged(ByVal txtBox As TextBox, ByVal tracBar As TrackBar)
        '当滑动条数值变化时,文本框里的数值始终和滑动条值相等
        txtBox.Text = tracBar.Value
    End Sub 'TrackBarValueChanged函数
    Private Sub btnApplySettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnApplySettings.Click
        My.Computer.Registry.SetValue(path, "MaxThumbSizePx", Convert.ToInt32(maxSizeTrackBar.Value), RegistryValueKind.DWord)
        My.Computer.Registry.SetValue(path, "MinThumbSizePx", Convert.ToInt32(miniSizeTrackBar.Value), RegistryValueKind.DWord)
        My.Computer.Registry.SetValue(path, "ThumbSpacingXPx", Convert.ToInt32(xsTrackBar.Value), RegistryValueKind.DWord)
        My.Computer.Registry.SetValue(path, "ThumbSpacingYPx", Convert.ToInt32(ysTrackBar.Value), RegistryValueKind.DWord)
        My.Computer.Registry.SetValue(path, "TopMarginPx", Convert.ToInt32(tmTrackBar.Value), RegistryValueKind.DWord)
        My.Computer.Registry.SetValue(path, "BottomMarginPx", Convert.ToInt32(bmTrackBar.Value), RegistryValueKind.DWord)
        My.Computer.Registry.SetValue(path, "LeftMarginPx", Convert.ToInt32(lmTrackBar.Value), RegistryValueKind.DWord)
        My.Computer.Registry.SetValue(path, "RightMarginPx", Convert.ToInt32(rmTrackBar.Value), RegistryValueKind.DWord)
        My.Computer.Registry.SetValue("HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Explorer/Advanced", "ExtendedUIHoverTime", Convert.ToInt32(dtTrackBar.Value), RegistryValueKind.DWord)
        '修改注册表后,重启explore.exe
        Dim Explorers() As Process = Process.GetProcessesByName("explorer")
        For Each Explorer As Process In Explorers
            Explorer.Kill()
        Next
        Process.Start("explorer.exe")
        Explorers = Nothing
    End Sub
#Region "KeyPress_Events"
    Private Sub maxSizeTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles maxSizeTextBox.KeyPress
        textBox_KeyPress(maxSizeTextBox, e)
    End Sub
    Private Sub miniSizeTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles miniSizeTextBox.KeyPress
        textBox_KeyPress(miniSizeTextBox, e)
    End Sub
    Private Sub xsTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles xsTextBox.KeyPress
        textBox_KeyPress(xsTextBox, e)
    End Sub
    Private Sub ysTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ysTextBox.KeyPress
        textBox_KeyPress(ysTextBox, e)
    End Sub
    Private Sub tmTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles tmTextBox.KeyPress
        textBox_KeyPress(tmTextBox, e)
    End Sub
    Private Sub bmTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles bmTextBox.KeyPress
        textBox_KeyPress(bmTextBox, e)
    End Sub
    Private Sub lmTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles lmTextBox.KeyPress
        textBox_KeyPress(lmTextBox, e)
    End Sub
    Private Sub rmTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles rmTextBox.KeyPress
        textBox_KeyPress(rmTextBox, e)
    End Sub
    Private Sub dtTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles dtTextBox.KeyPress
        textBox_KeyPress(dtTextBox, e)
    End Sub
#End Region
#Region "TextBox_Changed"
    Private Sub miniSizeTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miniSizeTextBox.TextChanged
        txtBox_TextChanged(miniSizeTextBox, miniSizeTrackBar)
    End Sub
    Private Sub maxSizeTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles maxSizeTextBox.TextChanged
        txtBox_TextChanged(maxSizeTextBox, maxSizeTrackBar)
    End Sub
    Private Sub xsTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xsTextBox.TextChanged
        txtBox_TextChanged(xsTextBox, xsTrackBar)
    End Sub
    Private Sub ysTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ysTextBox.TextChanged
        txtBox_TextChanged(ysTextBox, ysTrackBar)
    End Sub
    Private Sub tmTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmTextBox.TextChanged
        txtBox_TextChanged(tmTextBox, tmTrackBar)
    End Sub
    Private Sub bmTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bmTextBox.TextChanged
        txtBox_TextChanged(bmTextBox, bmTrackBar)
    End Sub
    Private Sub lmTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lmTextBox.TextChanged
        txtBox_TextChanged(lmTextBox, lmTrackBar)
    End Sub
    Private Sub rmTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rmTextBox.TextChanged
        txtBox_TextChanged(rmTextBox, rmTrackBar)
    End Sub
    Private Sub dtTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtTextBox.TextChanged
        If dtTextBox.Text <> "" Then
            'Delay Time最大值是9999
            Try
                dtTrackBar.Value = dtTextBox.Text
                If dtTrackBar.Value > 9999 Then
                    Throw New Exception
                End If
            Catch ex As Exception
                dtTrackBar.Value = 512
                dtTextBox.Text = "512"
            End Try
        End If
        '如果值为空
        If dtTextBox.Text = "" Then
            dtTrackBar.Value = 0
            dtTextBox.Text = ""
        End If
    End Sub
#End Region
#Region "TrackBar_Changed"
    Private Sub maxSizeTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles maxSizeTrackBar.ValueChanged
        trackBar_ValueChanged(maxSizeTextBox, maxSizeTrackBar)
    End Sub
    Private Sub miniSizeTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miniSizeTrackBar.ValueChanged
        trackBar_ValueChanged(miniSizeTextBox, miniSizeTrackBar)
    End Sub
    Private Sub xsTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xsTrackBar.ValueChanged
        trackBar_ValueChanged(xsTextBox, xsTrackBar)
    End Sub
    Private Sub ysTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ysTrackBar.ValueChanged
        trackBar_ValueChanged(ysTextBox, ysTrackBar)
    End Sub
    Private Sub tmTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmTrackBar.ValueChanged
        trackBar_ValueChanged(tmTextBox, tmTrackBar)
    End Sub
    Private Sub bmTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bmTrackBar.ValueChanged
        trackBar_ValueChanged(bmTextBox, bmTrackBar)
    End Sub
    Private Sub lmTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lmTrackBar.ValueChanged
        trackBar_ValueChanged(lmTextBox, lmTrackBar)
    End Sub
    Private Sub rmTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rmTrackBar.ValueChanged
        trackBar_ValueChanged(rmTextBox, rmTrackBar)
    End Sub
    Private Sub dtTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtTrackBar.ValueChanged
        trackBar_ValueChanged(dtTextBox, dtTrackBar)
    End Sub
#End Region
    Private Sub btnRestoreDefaults_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRestoreDefaults.Click
        My.Computer.Registry.SetValue(path, "MaxThumbSizePx", 200, RegistryValueKind.DWord)
        My.Computer.Registry.SetValue(path, "MinThumbSizePx", 200, RegistryValueKind.DWord)
        My.Computer.Registry.SetValue(path, "ThumbSpacingXPx", 16, RegistryValueKind.DWord)
        My.Computer.Registry.SetValue(path, "ThumbSpacingYPx", 16, RegistryValueKind.DWord)
        My.Computer.Registry.SetValue(path, "TopMarginPx", 16, RegistryValueKind.DWord)
        My.Computer.Registry.SetValue(path, "BottomMarginPx", 16, RegistryValueKind.DWord)
        My.Computer.Registry.SetValue(path, "LeftMarginPx", 16, RegistryValueKind.DWord)
        My.Computer.Registry.SetValue(path, "RightMarginPx", 16, RegistryValueKind.DWord)
        My.Computer.Registry.SetValue("HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Explorer/Advanced", "ExtendedUIHoverTime", 400, RegistryValueKind.DWord)
        maxSizeTextBox.Text = "200"
        miniSizeTextBox.Text = "200"
        xsTextBox.Text = "16"
        ysTextBox.Text = "16"
        tmTextBox.Text = "16"
        bmTextBox.Text = "16"
        lmTextBox.Text = "16"
        rmTextBox.Text = "16"
        dtTextBox.Text = "400"
        '修改注册表后,重启explore.exe
        Dim Explorers() As Process = Process.GetProcessesByName("explorer")
        For Each Explorer As Process In Explorers
            Explorer.Kill()
        Next
        Process.Start("explorer.exe")
        Explorers = Nothing
    End Sub
    Private Sub mainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        maxSizeTextBox.Text = "200"
        miniSizeTextBox.Text = "200"
        xsTextBox.Text = "16"
        ysTextBox.Text = "16"
        tmTextBox.Text = "16"
        bmTextBox.Text = "16"
        lmTextBox.Text = "16"
        rmTextBox.Text = "16"
        dtTextBox.Text = "400"
        On Error Resume Next
        maxSizeTextBox.Text = My.Computer.Registry.GetValue(path, "MaxThumbSizePx", Nothing).ToString
        miniSizeTextBox.Text = My.Computer.Registry.GetValue(path, "MinThumbSizePx", Nothing).ToString()
        xsTextBox.Text = My.Computer.Registry.GetValue(path, "ThumbSpacingXPx", Nothing).ToString()
        ysTextBox.Text = My.Computer.Registry.GetValue(path, "ThumbSpacingYPx", Nothing).ToString()
        tmTextBox.Text = My.Computer.Registry.GetValue(path, "TopMarginPx", Nothing).ToString()
        bmTextBox.Text = My.Computer.Registry.GetValue(path, "BottomMarginPx", Nothing).ToString()
        lmTextBox.Text = My.Computer.Registry.GetValue(path, "LeftMarginPx", Nothing).ToString()
        rmTextBox.Text = My.Computer.Registry.GetValue(path, "RightMarginPx", Nothing).ToString()
        dtTextBox.Text = My.Computer.Registry.GetValue("HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Explorer/Advanced", "ExtendedUIHoverTime", Nothing).ToString
    End Sub
End Class

  程序界面:

个性化你的Windows 7 Taskbar Thumbnail

  出处:http://www.cnblogs.com/technology/

  本文示例源代码或素材下载

标签: