Overlay Icon Windows 7 任务栏开发之覆盖图标( 二 )


internal static void SetWindowProperty(IntPtr hwnd, PropertyKey propkey, 
string value) 
{ 
// Get the IPropertyStore for the given window handle 
IPropertyStore propStore = GetWindowPropertyStore(hwnd); 
 
// Set the value 
PropVariant pv = new PropVariant(); 
pv.SetString(value); 
propStore.SetValue(ref propkey, ref pv); 
 
// Dispose the IPropertyStore and PropVariant 
Marshal.ReleaseComObject(propStore); 
pv.Clear(); 
}
程序改好后,就可以使用SetApplicationIdForSpecificWindow(IntPtr, String) 干活了:
Window newWindow = new TestWindow(); 
newWindow.Show(); 
WindowInteropHelper helper = new WindowInteropHelper(newWindow); 
IntPtr ptr = helper.Handle;
TaskbarManager.Instance.SetApplicationIdForSpecificWindow(ptr, "AppID");
修改了TestWindow 的AppID,两个窗口的任务栏图标才真正的完成了分离:
通过SetOverlayIcon(IntPtr, Icon, String) 来设置指定窗口(TestWindow)的Overlay Icon:
TaskbarManager.Instance.SetOverlayIcon(ptr, icon, "Overlay Icon Demo");
分离后再来看看效果,只显示MainWindow 图标:
两个窗口的图标都显示:
【Overlay Icon Windows 7 任务栏开发之覆盖图标】出处:http://www.cnblogs.com/gnIElee/

推荐阅读