久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

Windows 7 任務(wù)欄開發(fā)之縮略圖預(yù)覽(Thumbnail)

瀏覽:9日期:2023-05-31 15:12:22

上一篇我們對(duì)任務(wù)欄進(jìn)度條的開發(fā)有了相應(yīng)的了解,本篇將對(duì)縮略圖預(yù)覽功能進(jìn)行研究。提起縮略圖預(yù)覽相信使用過Windows 7 的朋友一定不會(huì)陌生,它可以說是Windows 7 的一大亮點(diǎn)。不論運(yùn)行的程序是否處于活動(dòng)狀態(tài),只要將鼠標(biāo)放在任務(wù)欄圖標(biāo)上便會(huì)出現(xiàn)當(dāng)前程序的預(yù)覽效果。如下圖所示我們可以快速的在IE 縮略圖中找到想看的網(wǎng)頁。當(dāng)然在Windows API 中也提供了許多開發(fā)縮略圖的工具,下面我們來看看如何使用它們。

TabbedThumbnail.TabbedThumbnail 方法

在默認(rèn)情況下Windows 7 會(huì)顯示應(yīng)用程序界面(如下圖),如果想替換或增加新的縮略圖,首先應(yīng)通過TabbedThumbnail 類的TabbedThumbnail 方法創(chuàng)建一個(gè)新的縮略圖(Thumbnail)。

在TabbedThumbnail 類中,有三個(gè)TabbedThumbnail 方法可以創(chuàng)建縮略圖:

//設(shè)定父窗口和子窗口/控件 public TabbedThumbnail(IntPtr parentWindowHandle, IntPtr windowHandle) { if (parentWindowHandle == IntPtr.Zero) throw new ArgumentException('Parent window handle cannot be zero.', 'parentWindowHandle'); if (windowHandle == IntPtr.Zero) throw new ArgumentException('Child control's window handle cannot be zero.', 'windowHandle'); WindowHandle = windowHandle; ParentWindowHandle = parentWindowHandle; }  //設(shè)定父窗口和子控件 public TabbedThumbnail(IntPtr parentWindowHandle, Control control) { if (parentWindowHandle == IntPtr.Zero) throw new ArgumentException('Parent window handle cannot be zero.', 'parentWindowHandle'); if (control == null) throw new ArgumentNullException('control'); WindowHandle = control.Handle; ParentWindowHandle = parentWindowHandle; }  //設(shè)定父窗口或WPF子控件,以及兩者的偏移量 public TabbedThumbnail(Window parentWindow, UIElement windowsControl, Vector peekOffset) { if (windowsControl == null) throw new ArgumentNullException('control'); if (parentWindow == null) throw new ArgumentNullException('parentWindow'); WindowHandle = IntPtr.Zero; WindowsControl = windowsControl; WindowsControlParentWindow = parentWindow; ParentWindowHandle = (new WindowInteropHelper(parentWindow)).Handle; PeekOffset = peekOffset; }

TabbedThumbnail.AddThumbnailPrevIEw 方法

通過AddThumbnailPreview 方法將TabbedThumbnail 添加到任務(wù)欄縮略圖中:

public void AddThumbnailPreview(TabbedThumbnail preview){… …}

TabbedThumbnailManager.SetActiveTab 方法

通過SetActiveTab 方法將指定的縮略圖、窗口句柄、Form控件、WPF控件設(shè)置為活動(dòng)狀態(tài)。例如,在IE 中我們打開了多個(gè)網(wǎng)頁標(biāo)簽,那么SetActiveTab 可以將其中一個(gè)標(biāo)簽設(shè)為當(dāng)前瀏覽頁。

public void SetActiveTab(TabbedThumbnail preview){… …} public void SetActiveTab(IntPtr windowHandle){… …} public void SetActiveTab(Control control){… …} public void SetActiveTab(UIElement WindowsControl){… …}

TabbedThumbnailManager.GetThumbnailPreview 方法

通過GetThumbnailPreview 方法獲取指定的窗口句柄、Form控件、WPF控件的縮略圖(TabbedThumbnail):

public TabbedThumbnail GetThumbnailPreview(IntPtr windowHandle){… …} public TabbedThumbnail GetThumbnailPreview(Control control){… …} public TabbedThumbnail GetThumbnailPreview(UIElement windowsControl){… …}

TabbedThumbnailManager.RemoveThumbnailPreview 方法

通過RemoveThumbnailPreview 方法將指定的縮略圖、窗口句柄、Form控件、WPF控件從任務(wù)欄縮略圖中刪除:

public void RemoveThumbnailPreview(TabbedThumbnail preview){… …} public void RemoveThumbnailPreview(IntPtr windowHandle){… …} public void RemoveThumbnailPreview(Control control){… …} public void RemoveThumbnailPreview(UIElement windowsControl){… …}

TabbedThumbnailManager.IsThumbnailPrevIEwAdded 方法

通過IsThumbnailPreviewAdded 方法判斷的縮略圖、窗口句柄、Form控件、WPF控件是否已添加,并返回Bool 值:

public bool IsThumbnailPreviewAdded(TabbedThumbnail preview){… …} public bool IsThumbnailPreviewAdded(IntPtr windowHandle){… …} public bool IsThumbnailPreviewAdded(Control control){… …} public bool IsThumbnailPreviewAdded(UIElement control){… …}

TabbedThumbnailManager.SetTabOrder 方法

通過SetTabOrder 方法調(diào)換兩個(gè)TabbedThumbnail 前后位置,注意第一個(gè)TabbedThumbnail 將調(diào)換到第二個(gè)TabbedThumbnail 的前面。

public void SetTabOrder(TabbedThumbnail previewToChange, TabbedThumbnail insertBeforePreview){… …}

效果演示

通過以上方法就能夠隨心所欲的設(shè)定縮略圖了,下面就將上面示意圖中的縮略圖改為Windows Logo 圖標(biāo),其中ui 即為XAML 代碼中控件的名稱(x:Name):

TabbedThumbnail newPreview = new TabbedThumbnail(Application.Current.MainWindow, ui, peekOffect); TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(newPreview); TaskbarManager.Instance.TabbedThumbnail.SetActiveTab(newPreview);

點(diǎn)擊“Set this image as thumbnail 前后對(duì)比,縮略圖變?yōu)榱?lt;Image> 控件:

修改前 

修改后

點(diǎn)擊“Add another thumbnail 后,可將<Button> 控件加入縮略圖中:

點(diǎn)擊 “Change thumbnail order 調(diào)換縮略圖前后位置:

另外,還可以通過TabbedThumbnail.Tooltip 屬性為縮略圖添加提示信息。當(dāng)鼠標(biāo)置于縮略圖上方時(shí),將會(huì)有相應(yīng)的ToolTip 顯示:

newPrevIEw.Tooltip = 'Welcome to Windows 7';

出處:http://www.cnblogs.com/gnielee/

標(biāo)簽: Windows系統(tǒng)
相關(guān)文章:
主站蜘蛛池模板: 夏津县| 林口县| 洪泽县| 绥棱县| 兰州市| 襄城县| 武城县| 南阳市| 朝阳区| 密云县| 博兴县| 乌拉特中旗| 白朗县| 余干县| 德州市| 鹤庆县| 寿光市| 措美县| 临桂县| 淮北市| 旺苍县| 商都县| 邵阳县| 奇台县| 东山县| 黄山市| 保康县| 龙海市| 郑州市| 武陟县| 张掖市| 永昌县| 剑阁县| 平果县| 上思县| 东海县| 大宁县| 杨浦区| 镇宁| 宁晋县| 宜春市|