Tweak DWM from your programs, Part 3
Published October 17th, 2008 in Windows VistaGlassLib 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, manipulate the Glass client area of windows and receive events which occur for them (Figure). Developers who target their applications for Far East users can also use the wrapper library to control the flow direction of controls and caption bar.
While the library wraps a big portion of the API exposed by DWM, the timing and performance counter part is to follow up shortly.
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:
-
Add a reference to the DwmWrapper.dll library to your project (from the Solution Explorer, select your project’s node, right click it and select Add Reference. From the new dialog box, browse the library file). 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.
-
Include the GlassLib namespace so that the Dwm-related classes can be accessed more easily.
-
When used in a System.Windows.Window, override the OnSourceInitialized method and then set up the event handlers.
-
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:
-
In VB .NET: Dwm.Glass(Me).Enabled = False
-
In C# .NET: Dwm.Glass[this].Enabled = false;
-
Note: this and Me refer to the calling instance, which is a System.Windows.Window in the example.
-
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:
-
Thickness foo = new Thickness(5, 30, 5, 20);// Assign foo to a Visual’s margin.Dwm.Glass[this].Margins = foo; // foo is implicitely casted to DwmMargins.
If you have any questions, suggestions or would like to report an issue, please feel free to use the Contact form.
Written in C# .NET. Binaries and the sources of a test application are available here; only binaries.
Search
About |
Currently, he is administering AeroXperience and coding using Visual Studio 2008 on Windows 7.
Latest
- Decoding FLAC audio files in C#
- Inline Tweet Translator
- Resizing forms while keeping aspect ratio
- Encoding uncompressed audio with FLAC in C#
- Indicating progress in console windows
- 2010
- Windows 7 – Какво ново?
- Most Valuable Professional and what’s to come
- Tweak DWM from your programs, Part 3
- Tweak DWM from your programs, Part 2



No Responses to “Tweak DWM from your programs, Part 3”
Please Wait
Leave a Reply