Skip to main content

Using The AeroGlass library


AeroGlass Library
Version 1.2

Contents:
·         Usage with Windows forms
·         Usage with WPF forms
The AeroGlass library accesses the dwmapidll to extend the frames of windows for use with the C# language, this gives the effect of having more glass areas on a window or making a window look as if it is completely glass. The library aims to make implementing this method easier so that you can achieve this effect with minimal code and will not have to access the dll yourself,version 1.2 of the library is compatible with both windows forms and WPF forms, though the implementation differs slightly. This documentation covers the implementations of both types.

Usage with windows forms
There are 2 ways of implementing glass on a Windows form using the AeroGlass library, one is to use the GlassPane controls AutoExtend property and the other is to use code, let us first take a look at the AutoExtend property method.
AutoExtend
Before we begin it is worth noting that if you use the AutoExtend method you can only place one GlassPane, if you place another it will not work or errors may occur, it is for this reason that AutoExtend is false by default.
For AutoExtend to work, the glass pane must be docked, this will be explained later in the code section. To make a form with an extended glass frame using this method, add the control to your toolbox by right clicking the toolbox and selecting choose items

Following this, place the GlassPane  control , dock it as you wish and set the AutoExtend property to true, here I have docked mine on the bottom of the form.




Now running the application should produce the following result:


Using Code
Now let us take a look at using code to implement an extended glass frame.When using code ,you are still required to use the GlassPane,this is because all the code actually does is extend the frame of the window inwards, if we just use the code and not the GlassPane the inner part of the window will still cover the extended frame. This can be seen if you look carefully at the image below.

To use the library ,we must first add a reference to the AeroGlass dll, placing a GlassPane on the form will automatically do this, then we add the using statement to use the Classes in  the library.
using AeroGlass;
Now, in the form class, create a new instance of the Glass class:
Glass g = newGlass();
Place a GlassPane on your form and dock it as you desire, I have docked mine on the bottom as I did previously, but this time AutoExtend is set to false. Then in the Form_Load event, call the extendFrame function:
g.extendFrame(0, glassPane1.Height, 0, 0, this);
The extendFrame function has the following parameters: intTop ,int Bottom, int Left, int Right Form form. ”this” refers to the current form. Note that I used the height of the GlassPane as my margin width for the bottom margin. Running this code will yield the same result as seen previously

Usage with WPF forms
Using the AeroGlass Library with a WPF form is a little different but the concept is still the same. Starting with a Blank WPF form, select the main grid in the center  of the form and give it a name ,have named mine mainGrid.



Next ,add a reference to the AeroGlass dll and include the following using statement in the code of your window:
using AeroGlass;

Then in the class:

WpfGlasswg = newWpfGlass();

Finally we add this line to the Window_loaded event:

wg.extendFrame((int)mainGrid.Height, 0, 0, 0, this);


As you can see, the structure of this last statement is the same as that used in the Windows Form, the only difference is that the height of mainGrid had to be cast as an integer. Running this should result in the following:



Don’t like a completely glass window, simply change the size of the grid or choose different properties and parameters to parse or overlay the window with different controls.

Here I have overlaid a semi-transparent rectangle to give a nice effect and added a semi-transparent textbox control:

Download PDF here

Comments

Popular posts from this blog

Setting up Qt Creator for assembly

After fiddling with inline asssembly (not very successfully) ,I recently decided to try writing proper assembly and compiling with NASM in Linux. After writing a hello world using gedit and having a terminal open for compiling,linking and running I had a thought.,there has to be a better way to do this. So I tried Qt Creator ,because I know it's easy to add custom build and run commands,and what do you know? I got it to work. Here's how,my screenshots and assembly code are in Linux but the set up should be the same regardless of the operating system,if you are not using Linux then just use the same commands you use to assemble in your operating system. First off ,create a new console application: I named mine ASM Rename the main.cpp to main.asm and delete all the text inside.then insert some assembly: Now open up the “Project” tab and edit the build settings,remove the current build and clean steps and remove the “-build-desktop” from the en...

Using delegates in Objective-C

Why use delegation? Well when writing Objective-C programs in Xcode we are encouraged to use the MVC(Model View Controller) structure.In MVC a model cannot send messages directly to a specific controller.This can become a problem if data in your model changes independantly and you need to update this information in your view via the controller(The model must never communicate directly with the view).This is where a delegate comes in,it allows messages to be sent from the model to a controller that is not specified in the model but is rather specified by the controller,in other words the controller specifies itself. If you dont really understand what im talking about so far ,don't worry.I didn't understand delegates either until I needed one,but hopefully by the end of this tutorial you will understand not only how to use a delegate ,but the reason you would want to use one. Program breakdown For this tutorial we will write a program that has a model that will change an...

Fix ssh -Y with other Macs OSX 10.8 Mountain Lion

You may have realised that when you try use ssh -Y on another Mac from Mountain Lion you get the following error : Warning: No xauth data; using fake authentication data for X11 forwarding.X11 forwarding request failed on channel 0 Fixing this error only takes some simple configuration. All you have to do is add these lines to the following files on both machines: /etc/sshd_config X11Forwarding yes XauthLocation /opt/X11/bin/xauth XauthLocation /usr/X11R6/bin/xauth /etc/ssh_config XauthLocation /opt/X11/bin/xauth XauthLocation /usr/X11R6/bin/xauth That should be all you need to get rid of the authentication error. Hope this was helpful.