您的位置:首页技术文章
文章详情页

个性化你的Windows 7 Taskbar Thumbnail

【字号: 日期:2023-05-29 13:21:44浏览:18作者:猪猪

昨天看到How To Geek里的一篇文章, 里面有个小程序做得觉得挺有意思, 那个程序可以改变Windows 7的缩略图大小, 缩略图与缩略图之间的距离, 以及上下左右的边距, 甚至还可以设置鼠标放到任务栏上多久显示出缩略图, 系统默认的是400ms, 感觉有点慢, 我把它调成了1, 鼠标一放上去就冒出缩略图, 感觉非常的爽. 当然这些都是靠更改注册表完成的.

我把那个程序下载下来, 用Reflector看一下那个程序, 终于知道是什么原理, 又花了好几个小时实现了一遍, 当然我写的代码肯定没人家好, 人家是美国的MVP, 我只是个菜鸟:)在这里把实现过程跟大家分享一下, 有哪些写的不好的地方, 欢迎指教.

改变缩略图后的大小(可以在这里面看电影了, 呵呵):

更改缩略图的X-Spacing和Y-Spacing后(可以看到效果还是很明显的):

程序的核心步骤:

在注册表目录HKEY_CURRENT_USER/Software/Microsoft/Windows /CurrentVersion/Explorer/Taskband下新建几个键:MaxThumbSizePx, MinThumbSizePx, ThumbSpacingXPx, ThumbSpacingYPx, TopMarginPx, BottomMarginPx, LeftMarginPx, RightMarginPx 分别用于控制缩略图尺寸, 两个缩略图直接的边距, 还有缩略图中内容的上下左右边距

在注册表目录HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Explorer/Advanced下新建一个键: ExtendedUIHoverTime

它用于控制缩略图显示的延迟时间(单位是ms)

每次更改完注册表的信息后, 要看到效果不需要重新开机, 只需要关闭explore.exe, 再重新打开即可.

Private Sub btnApplySettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnApplySettings.ClickMy.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.exeDim Explorers() As Process = Process.GetProcessesByName('explorer')For Each Explorer As Process In ExplorersExplorer.Kill()NextProcess.Start('explorer.exe')Explorers = NothingEnd Sub

不用担心的是, 如果你设置这个设置那个, 搞的很乱, 你可以恢复系统默认值:

Private Sub btnRestoreDefaults_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRestoreDefaults.ClickMy.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.exeDim Explorers() As Process = Process.GetProcessesByName('explorer')For Each Explorer As Process In ExplorersExplorer.Kill()NextProcess.Start('explorer.exe')Explorers = NothingEnd Sub

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

Imports Microsoft.Win32

Public Class mainFormDim 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') Thene.Handled = TrueIf Convert.ToInt32(e.KeyChar).Equals(8) Thene.Handled = FalseEnd IfElsee.Handled = FalseEnd IfEnd Sub 'KeyPress函数Private Sub txtBox_TextChanged(ByVal txtBox As TextBox, ByVal trackBar As TrackBar)'TextBox里的值发生变化后'如果值不为空If txtBox.Text <> '' Then'滑动条的值等于文本框内的数值TrytrackBar.Value = txtBox.TextIf trackBar.Value > 512 Then '如果滑动条的值超过512则抛出一个异常Throw New ExceptionEnd IfCatch ex As ExceptiontrackBar.Value = 512txtBox.Text = '512'End TryEnd If'如果值为空If txtBox.Text = '' Then'滑动条的值置为0,文本框的值置为空trackBar.Value = 0txtBox.Text = ''End IfEnd Sub 'TextChanged函数Private Sub trackBar_ValueChanged(ByVal txtBox As TextBox, ByVal tracBar As TrackBar)'当滑动条数值变化时,文本框里的数值始终和滑动条值相等txtBox.Text = tracBar.ValueEnd Sub 'TrackBarValueChanged函数Private Sub btnApplySettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnApplySettings.ClickMy.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.exeDim Explorers() As Process = Process.GetProcessesByName('explorer')For Each Explorer As Process In ExplorersExplorer.Kill()NextProcess.Start('explorer.exe')Explorers = NothingEnd Sub#Region 'KeyPress_Events'Private Sub maxSizeTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles maxSizeTextBox.KeyPresstextBox_KeyPress(maxSizeTextBox, e)End SubPrivate Sub miniSizeTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles miniSizeTextBox.KeyPresstextBox_KeyPress(miniSizeTextBox, e)End SubPrivate Sub xsTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles xsTextBox.KeyPresstextBox_KeyPress(xsTextBox, e)End SubPrivate Sub ysTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ysTextBox.KeyPresstextBox_KeyPress(ysTextBox, e)End SubPrivate Sub tmTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles tmTextBox.KeyPresstextBox_KeyPress(tmTextBox, e)End SubPrivate Sub bmTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles bmTextBox.KeyPresstextBox_KeyPress(bmTextBox, e)End SubPrivate Sub lmTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles lmTextBox.KeyPresstextBox_KeyPress(lmTextBox, e)End SubPrivate Sub rmTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles rmTextBox.KeyPresstextBox_KeyPress(rmTextBox, e)End SubPrivate Sub dtTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles dtTextBox.KeyPresstextBox_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.TextChangedtxtBox_TextChanged(miniSizeTextBox, miniSizeTrackBar)End SubPrivate Sub maxSizeTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles maxSizeTextBox.TextChangedtxtBox_TextChanged(maxSizeTextBox, maxSizeTrackBar)End SubPrivate Sub xsTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xsTextBox.TextChangedtxtBox_TextChanged(xsTextBox, xsTrackBar)End SubPrivate Sub ysTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ysTextBox.TextChangedtxtBox_TextChanged(ysTextBox, ysTrackBar)End SubPrivate Sub tmTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmTextBox.TextChangedtxtBox_TextChanged(tmTextBox, tmTrackBar)End SubPrivate Sub bmTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bmTextBox.TextChangedtxtBox_TextChanged(bmTextBox, bmTrackBar)End SubPrivate Sub lmTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lmTextBox.TextChangedtxtBox_TextChanged(lmTextBox, lmTrackBar)End SubPrivate Sub rmTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rmTextBox.TextChangedtxtBox_TextChanged(rmTextBox, rmTrackBar)End SubPrivate Sub dtTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtTextBox.TextChangedIf dtTextBox.Text <> '' Then'Delay Time最大值是9999TrydtTrackBar.Value = dtTextBox.TextIf dtTrackBar.Value > 9999 ThenThrow New ExceptionEnd IfCatch ex As ExceptiondtTrackBar.Value = 512dtTextBox.Text = '512'End TryEnd If'如果值为空If dtTextBox.Text = '' ThendtTrackBar.Value = 0dtTextBox.Text = ''End IfEnd Sub#End Region#Region 'TrackBar_Changed'Private Sub maxSizeTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles maxSizeTrackBar.ValueChangedtrackBar_ValueChanged(maxSizeTextBox, maxSizeTrackBar)End SubPrivate Sub miniSizeTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miniSizeTrackBar.ValueChangedtrackBar_ValueChanged(miniSizeTextBox, miniSizeTrackBar)End SubPrivate Sub xsTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xsTrackBar.ValueChangedtrackBar_ValueChanged(xsTextBox, xsTrackBar)End SubPrivate Sub ysTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ysTrackBar.ValueChangedtrackBar_ValueChanged(ysTextBox, ysTrackBar)End SubPrivate Sub tmTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmTrackBar.ValueChangedtrackBar_ValueChanged(tmTextBox, tmTrackBar)End SubPrivate Sub bmTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bmTrackBar.ValueChangedtrackBar_ValueChanged(bmTextBox, bmTrackBar)End SubPrivate Sub lmTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lmTrackBar.ValueChangedtrackBar_ValueChanged(lmTextBox, lmTrackBar)End SubPrivate Sub rmTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rmTrackBar.ValueChangedtrackBar_ValueChanged(rmTextBox, rmTrackBar)End SubPrivate Sub dtTrackBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtTrackBar.ValueChangedtrackBar_ValueChanged(dtTextBox, dtTrackBar)End Sub#End RegionPrivate Sub btnRestoreDefaults_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRestoreDefaults.ClickMy.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.exeDim Explorers() As Process = Process.GetProcessesByName('explorer')For Each Explorer As Process In ExplorersExplorer.Kill()NextProcess.Start('explorer.exe')Explorers = NothingEnd SubPrivate Sub mainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadmaxSizeTextBox.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 NextmaxSizeTextBox.Text = My.Computer.Registry.GetValue(path, 'MaxThumbSizePx', Nothing).ToStringminiSizeTextBox.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).ToStringEnd SubEnd Class

程序界面:

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

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

标签: Windows系统
相关文章: