CodeProject's Upload Wont work for me right now, so head over to http://www.freewebs.com/omnicodersfiles/ColorSlider.rar
to download!
Introduction
One problem with Vista Glass That Bothered me was how screwed up controls get
When you put them on Glass. Basicly, it is GDI not drawing correctly, but I need not get into that. After Trying every method I found online, and none working, I decided to do it myself. I made a article about fixing buttons and textboxs, which I deleted because it didn't work very good. This article is going to show you a cool workaround for this, and give you the ability to do some cool form effects!
Background
When I was initial faced with this problem, I responded by, what else, google. After finding nothing but C++ examples and Broken Tutorials for c# that didn't work, along with millions of form posts about this, I realized I was on my own. The First Idea that ran thorugh my head when I saw how bad Controls look on glass:

Blech! thats what it COULD look like. On the other hand, if the user was not over white, it may look like this:

Thats the same form as above, so as you can see, you are at the mercy of the users bacckdrop and color scheme. How do we deal with this?
The first thing that I thought of was "Find some way [to] make sure the backround is ALWAYS the right color(EG. Black)
I immediatly dismissed this idea, and moved on, trying everything I thought could have any effect. Eventually, I realized that I was out of Ideas. So, what was left to try? My Original idea. Having a Borderless form 'Attached' to the back of the real form. That way, the backround can be controlled. This brings up another problem though. No Transparency Anymore! One Problem leads to another, eh? Well I figured this out too, and it is in the next section.
Quick Screenshot of a basic example from the article:

^ My theme is still set to Totaly clear in this shot! ^
^ Also, that is NOT my phone number in the masked text box! ^
Using the code
To use this method, you must first create a new form.
With a project open, Right click on the project in the solution explorer, and select 'Add'
Then select 'Windows Form...'. Give your form a name, like "Testform".
Now, resize the form and place some (Standerd) controls.
Double Click on The Forum, and paste the following code:
Testform.Backcolor = Color.Black
Basicly, this code makes the form's backround black at runtime, but not in the form editor. The next thing to do is refrence the DWM API to make the form glassy. Add the following code before form_load(After adding the below file to your project:
Download DWMCODE.vb (CODE NOT WRITTEN BY ME! ITS FROM THE VISTA CONTROLS LIB)
Dim foo = me.size.height * 5
DwmExtendFrameIntoClientArea(Me.Handle, New Margins(foo, foo, foo, foo))
Now, run your project. It should look like the 'bad' picture shown above( If not, drag the form over a white area, and you will know what I mean.)
So, how do we fix this? Simple, make sure the backround is what we want it to be!
How is this done? Well, a little bit more code, and you will see!
First, Create another new form. Set the FormBorderStyle to None, and set the backcolor to black.
Now go back to the first form, and scroll the properties window to the size property. Copy it and paste it into form2's size property. Now we have 2 equally Sized forms!
Make one of the controls on form1 do the following when clicked:
Form2.Show()
Me.Hide()
Me.Show()
This makes the black form appear, then makes sure it is behind our main form. This looks a little better, but try dragging the form. Oops! The black part doesnt move! Well, this is another simple fix. In the code editor, go to the Move event of Form1, and enter this code:
Form2.Location = Me.Location
Now Click F5 and moving will work, but Resizing still doesnt work!
Next, add this code to Form1's Resize Event:
Form2.Size = Me.Size
Wow! This is working really good so far! Now try clicking Alt+Tab(Not Win+Tab!)
The Black Form Shows Up! Oh no! This is bad. Switch to the black form, and it will appear in front of our form! How are we going to solve this tricky problem? Simple!
Make windows Think that it is not the right type of window. Go in to Form2(Design) and Change the FormBorderStyle to FixedToolWindow. Also, go back to form1 and update form2s size agian.
Now it doesnt show up in alt+tab, but it has a window border. Hmm... Well, this can be fixed, too. Just set the forms ShowInTaskbar, ControlBox and ShowIcon Properties to false, then set the Text of the form to Be Blank.
Wahla! No Border, or Alt+Tab! It's Great Right?
Now, try to figure out the next problem yourself! Seriously! Run The App, and screw with it for a bit. Try to find the next problem before scrolling down. Give yourself about 5 Minutes.
>>>>SPOILER<<<<
The Problem is that opening another window can cause the Main form and the black form to be seperated(If the other window is in between)
I still havent prefected this part yet, but In most cases, setting the Topmost property of both forms to true will fix it. Any other Top most windows could still cause this problem, though, so If anyone has a better solution, Im all ears.
Now, Run The application. Pretty Nice, Ehh?
Try adding a textbox to the form, and reverse it's backcolor and forecolor properties. Neat!
But, We have lost Transparency! The whole point of this WAS to use Aero glass, right? So how useful would it be if it wasnt Glass anymore?
Well, simply set the Opacity of Form2 to 75 or 50(Or in between)
Now it will look like the good example above!
In the projet, there are some commented out lines in the Form2 File. You can uncomment them and try the effect they provide out if you want, but I am not going to go over it, as it is not related to my topic. You can add pictures, shapes or even videos to form2, to make a cool backround! If you come up with any other Effects, post them below!.
I will integrate getting the DWM color (from my other article) into this one soon, as I have a cool Idea for an effect.
Points of Interest
This is actually making use of Multiple Transparency APIs! The Opacity(Which turns it into a layerd window), and Dwmapi.dll, the Dll for Aero Glass.
New Effects
My First New Effect: DWM Color Grabbing
Private Const WM_DWMCOLORIZATIONCOLORCHANGED As Integer = 800
Protected Overloads Overrides Sub WndProc(ByRef msg As Message)
If msg.Msg = WM_DWMCOLORIZATIONCOLORCHANGED Then
Dim aarrggbb = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorizationColor", "00000000")
Dim argb = Convert.ToInt32(CLng(aarrggbb.ToString), 10)
Dim argbcol = System.Drawing.Color.FromArgb(argb)
Form2.backcolor = argbcol
End If
MyBase.WndProc(msg)
End Sub
Note that you will need to copy the code in the if statemnet into Form_Load as well:
Dim aarrggbb = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorizationColor", "00000000")
Dim argb = Convert.ToInt32(CLng(aarrggbb.ToString), 10)
Dim argbcol = System.Drawing.Color.FromArgb(argb)
Then:
form2.backcolor = argbcol
History
Added a New Effect!
Updated the Info for the New Effect