Skip to main content

Using The AeroGlass library

AeroGlass Library
Version 1.2

·         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.
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


Popular posts from this blog

Running Node.js alongside IIS on Windows

Most of the time when you are looking for a way to run Node.js as a production server on Windows you will just run into IISNode , now IISNode is a great thing ,but I'm a fan of choice and most importantly , not a fan of XML web config files.

I wanted to run my node server on what ever port I wished,or maybe even a different server and just have IIS reroute the traffic from a particular URL to the node process(so a proxy), this allows you to still manage your own load balancing and possibly scale up from that point without having to bother with IIS again.

So first things first you will want to download and install the URL Rewrite and ARR modules for IIS

ARR (Application Request Routing)URL Rewrite Once thats done lets crack open IIS and open up Application Request Routing, then navigate to Server Proxy Settings and Check Enable Proxy and Apply.

Now lets create an an application on our Default Website that will link our url to the node process, here im directing it to an empty direc…

Half-Life 2 for OSX , how well does it run?

Earlier this week Valve advertised Half-Life 2 for the Mac with the best advert I have ever seen. They took the old 1984 Mac advert and re-created it using the source engine and characters from the game. As if the awesome(albeit 35 second) entertainment wasn't enough they offered the game at $3.40 for a limited period. It was not shortly afterwards that I made my first ever purchase on Steam(its kind of strange buying a game and not getting a box with it).

The game purchase actually allows you to download the OSX or Windows version of the game , depending on the platform you are logged in to .This is great , because I have a PC with some decent gaming power and my Mac Mini (which I naturally wanted to test on) and wow ,the OSX version runs pretty darn well,especially considering that my mac mini is running only an intel HD3000.

I was surprised how well the game performed on high settings , the gameplay was smooth with the default high settings , reaching frame-rates up …

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 end of the build directory line.