国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

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

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

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

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

TabbedThumbnail.TabbedThumbnail 方法

在默認(rèn)情況下Windows 7 會(huì)顯示應(yīng)用程序界面(如下圖),如果想替換或增加新的縮略圖,首先應(yīng)通過(guò)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 方法

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

public void AddThumbnailPreview(TabbedThumbnail preview){… …}

TabbedThumbnailManager.SetActiveTab 方法

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

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

TabbedThumbnailManager.GetThumbnailPreview 方法

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

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

TabbedThumbnailManager.RemoveThumbnailPreview 方法

通過(guò)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 方法

通過(guò)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 方法

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

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

效果演示

通過(guò)以上方法就能夠隨心所欲的設(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)換縮略圖前后位置:

另外,還可以通過(guò)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)文章:
主站蜘蛛池模板: 康马县| 甘肃省| 许昌县| 博爱县| 孟州市| 蓬莱市| 宁陕县| 马公市| 曲松县| 津市市| 饶阳县| 那坡县| 土默特右旗| 措勤县| 黄平县| 光泽县| 从江县| 香港 | 怀集县| 平阴县| 伊金霍洛旗| 务川| 南京市| 乳源| 泰和县| 吉林省| 兴化市| 铜山县| 衡阳县| 阿合奇县| 吉木乃县| 江孜县| 唐河县| 神池县| 鄯善县| 苍山县| 黄陵县| 晋中市| 毕节市| 尖扎县| 铁岭市|