<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Stanimir Stoyanov's Blog</title>
	<link>http://stoyanoff.info/blog</link>
	<description></description>
	<pubDate>Mon, 21 Jul 2008 21:35:50 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.1</generator>
	<language>en</language>
			<item>
		<title>GlassLib for WPF</title>
		<link>http://stoyanoff.info/blog/code/glasslib/wpf/</link>
		<comments>http://stoyanoff.info/blog/code/glasslib/wpf/#comments</comments>
		<pubDate>Tue, 03 Oct 2006 08:00:08 +0000</pubDate>
		<dc:creator>Stanimir Stoyanov</dc:creator>
		
	<category>Windows Vista</category>
		<guid isPermaLink="false">http://www.stoyanoff.info/blog/code/glasslib-for-wpf/</guid>
		<description><![CDATA[GlassLib is a wrapper library for the Desktop Window Manager API and is to be used by developers which would like their applications to take advantage of .NET Framework and Windows Presentation Foundation in particular.
It can be used to control the Desktop Composition due to application requirements, create and reference Live Thumbnails of arbitrary windows, [...]]]></description>
			<content:encoded><![CDATA[<p align="left"><strong>GlassLib</strong> is a wrapper library for the <em>Desktop Window Manager API</em> and is to be used by developers which would like their applications to take advantage of .NET Framework and Windows Presentation Foundation in particular.</p>
<p align="left">It can be used to control the Desktop Composition due to application requirements, create and reference Live Thumbnails of arbitrary windows, manipulate the Glass client area of windows and receive events which occur for them (<a href="/code/wpf/DwmWrapper_Common.png" rel="lightbox[images1]" target="_blank">Figure</a>). Developers who target their applications for Far East users can also use the wrapper library <a href="/code/wpf/DwmWrapper_Rtl.png" rel="lightbox[images1]" target="_blank">to control the flow direction of controls and caption bar</a>.</p>
<p align="left">While the library wraps a big portion of the API exposed by DWM, the timing and performance counter part is to follow up shortly.</p>
<p align="left">Documentation and a test application are provided. The usage of the wrapper library is pretty much straight-forward. Following is a list of several key facts:</p>
<ul>
<li>
<div align="left">Add a reference to the DwmWrapper.dll library to your project (from the Solution Explorer, select your project&#8217;s node, right click it and select <strong>Add Reference</strong>. From the new dialog box, browse the library file). <em>Please note that the library is compiled against the .NET Framework 2.0 therefore it can only be used in projects compiled against it, or a newer version.</em></div>
</li>
<li>
<div align="left">Include the GlassLib namespace so that the Dwm-related classes can be accessed more easily.</div>
</li>
<li>
<div align="left">When used in a System.Windows.Window, override the OnSourceInitialized method and then set up the event handlers.</div>
</li>
<li>
<div align="left">Per-window options can be set using the Dwm.Glass, Blur, Events, NonClientArea and Flip3D. This is available by using the indexer (default property) of these properties. The value passed to the indexer can be an IntPtr - handle to a window or a System.Windows.Media.Visual whose window handle will be manipulated. E.g:</div>
</li>
<ul>
<li>
<div align="left">In VB .NET: <font face="Courier New">Dwm.Glass<em><strong>(Me)</strong></em>.Enabled = False</font></div>
</li>
<li>
<div align="left">In C# .NET: <font face="Courier New">Dwm.Glass<em><strong>[this]</strong></em>.Enabled = false;</font></div>
</li>
<ul>
<li>
<div align="left">Note: <strong>this</strong> and <strong>Me</strong> refer to the calling instance, which is a System.Windows.Window in the example.</div>
</li>
</ul>
</ul>
<li>
<div align="left">The Dwm* structures have implicit operators. This allows for casting Windows Presentation Foundation Rect and Thickness implicitely to DwmRect and DwmMargins, respectively. For instance, the following expression will be valid:</div>
</li>
<ul>
<li>
<div align="left"><font face="Courier New"><font size="2"><font size="2"><font color="#008080" size="2">Thickness<font size="2"> foo = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">Thickness</font><font size="2">(5, 30, 5, 20);</font> </font></font></font></font></div>
<div align="left"><font face="Courier New"><font size="2"><font size="2"><font color="#008000" size="2">// Assign foo to a Visual&#8217;s margin.</font></font></font></font></div>
<div align="left"><font face="Courier New"><font size="2"><font color="#008080" size="2">Dwm<font size="2">.Glass[</font><font color="#0000ff" size="2">this</font><font size="2">].Margins = foo; </font><font color="#008000" size="2">// foo is implicitely casted to DwmMargins.</font></font></font></font>     </div>
</li>
</ul>
</ul>
<div align="left">
<p align="center"><a href="/code/wpf/DwmWrapper_Common.png" rel="lightbox[images2]" target="_blank"><img title="GlassLib Test Application" alt="GlassLib Test Application" src="/code/wpf/DwmWrapper_Common.th.png" /></a> <a href="/code/wpf/DwmWrapper_Rtl.png" rel="lightbox[images2]" target="_blank"><img title="GlassLib Test Application - Right-To-Left Layout" alt="GlassLib Test Application - Right-To-Left Layout" src="/code/wpf/DwmWrapper_Rtl.th.jpg" /></a></p>
<p align="left">If you have any questions, suggestions or would like to report an issue, please feel free to use the <a href="/contact/">Contact form</a>.</p>
<blockquote>
<p align="left">Written in C# .NET. Binaries and the sources of a test application are available <a href="/code/wpf/GlassLibWpf.070626-2042.zip">here</a>; <a href="/code/wpf/GlassLibWpf.bin.070626-2042.zip">only binaries</a>.</p>
</blockquote>
<p> </div>
]]></content:encoded>
			<wfw:commentRSS>http://stoyanoff.info/blog/code/glasslib/wpf/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>
