03-21-2013, 16:33
Hey guys,
I just found method to make program look cool.
You don't need to use WindowsAPICodePack and another stuff. It's just 20 lines.
Let's start.
First off you need to add those DLLImports in your project code:
(Thanks to some stackoverflow users for it)
Now create class called EGAPI ( Epic glass api or whatever ) and create struct for Margins, since it's c++ struct, can't be used in c#.
2. Making some warnings and enabling GLASS API if it is supported by system.
Well, as you (maybe) know, those functions are in dwmapi.dll, but you will not see result without dwm.exe. ( Starts automaticly on PC launching. )
Let's see which OS we are using ( Win7, 8, Vista ) only supported.
Now lets enable/load our glass api.
Introducting glass api into form
You can find 'Main()' method in your Form.cs.
Put the following code next:
It will enable glass api into your form, but it won't show! Lets do something special to show it.
1. You need to find 'Panel' in Constructor, put it somewhere in form where you want .
Double click on your form, it will make 'Form_Load()' method.
Lets code some lines to see glassy effect.
Thanks to some stackoverflow users for 'TransparentyKey' stuff.
Now click F5, and you will see something like this:
(Look down to see glassy effect)
(Screenies by EasyCapture)
Thanks for reading, it can be super useless, but eh.
I just found method to make program look cool.
You don't need to use WindowsAPICodePack and another stuff. It's just 20 lines.
Let's start.
First off you need to add those DLLImports in your project code:
(Thanks to some stackoverflow users for it)
Code:
#region Epic glass API imports
[DllImport("dwmapi.dll")]
public static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Margins pMargins);
[DllImport("dwmapi.dll")]
public static extern void DwmIsCompositionEnabled(ref bool isEnabled);
#endregion
Now create class called EGAPI ( Epic glass api or whatever ) and create struct for Margins, since it's c++ struct, can't be used in c#.
Code:
public struct Margins
{
public int Left, Right, Top, Bottom;
}
2. Making some warnings and enabling GLASS API if it is supported by system.
Well, as you (maybe) know, those functions are in dwmapi.dll, but you will not see result without dwm.exe. ( Starts automaticly on PC launching. )
Let's see which OS we are using ( Win7, 8, Vista ) only supported.
Code:
public static bool IsRightOS()
{
if (Environment.OSVersion.Version.Major < 6) // could be changed to 7 or 5
{
// eh
Console.WriteLine("dwmapi - Glass api is not supported.");
return false;
}
return true; // it seems there are no errors
}
Now lets enable/load our glass api.
Code:
if(!IsRightOS()) // os isn't win7,8,vista
return;
bool issupported = false;
GPI.DwmIsCompositionEnabled(ref issupported); // could be OUT
return issupported;
Introducting glass api into form
You can find 'Main()' method in your Form.cs.
Put the following code next:
Code:
GPI.Margins margin;
margin.Top = 2000; // you can change values
margin.Left = 0;
margin.Right = 0;
margin.Bottom = 0;
GlassAPI.DwmExtendFrameIntoClientArea(this.Handle, ref margin);
It will enable glass api into your form, but it won't show! Lets do something special to show it.
1. You need to find 'Panel' in Constructor, put it somewhere in form where you want .
Double click on your form, it will make 'Form_Load()' method.
Lets code some lines to see glassy effect.
Thanks to some stackoverflow users for 'TransparentyKey' stuff.
Code:
Color color = Color.FromArgb(255, 220, 220, 220); // transparentyyy
panel1.BackColor = color; // can be fore
this.TransparencyKey = color;
Now click F5, and you will see something like this:
(Look down to see glassy effect)
(Screenies by EasyCapture)
Thanks for reading, it can be super useless, but eh.