个性化你的Windows 7 Taskbar Thumbnail

        昨天看到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.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

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

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

程序界面

程序下载:/Files/technology/Window7TaskbarPersonalize.zip
posted @ 2010-07-03 15:08  Create Chen  阅读(2302)  评论(9编辑  收藏  举报