Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tutorial Making MORE glass in your form.
#1
Information 
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)
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)
[Image: A9kDX.png]
(Screenies by EasyCapture)

Thanks for reading, it can be super useless, but eh.
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#2
So everyone's making plugin addons now?
Reply

#3
(03-21-2013, 16:43)kokole Wrote: So everyone's making plugin addons now?

It's SP. And i had idea before @JariZ Dumb Bitch
[Image: 74936645-happy.gif]
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#4
Wait, but can you mix different languages in single project in Visual Studio? (Not sure, but I think I have seen C# and C++ both in 1 project working fine together. Or is it just me?)
And what is this line at the very bottom of form? Is it supposed to be there?
Reply

#5
(03-21-2013, 18:35)Borealis Wrote: Wait, but can you mix different languages in single project in Visual Studio? (Not sure, but I think I have seen C# and C++ both in 1 project working fine together. Or is it just me?)
And what is this line at the very bottom of form? Is it supposed to be there?

Maybe some kind of plugins for VC exists, i don't know.
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#6
Oh because it's such a freakin original idea, right, sailor?
Even if you didn't tell me your 'genius' idea, I would've still done it, You've got nothing to do with it.

FYI you're doing it wrong:
[Image: hbrkR.png]
Reply

#7
(03-21-2013, 19:26)JariZ Wrote: Oh because it's such a freakin original idea, right, sailor?
Even if you didn't tell me your 'genius' idea, I would've still done it, You've got nothing to do with it.

FYI you're doing it wrong:
[Image: hbrkR.png]

You said you won't talk to me anymore. I said that i will remember it :x so eh?
I knew already, i was lazy to move damn panel.

Yeah it's so original idea, why not?
[Image: q8Hyh.png]
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#8
Well I found it helpful, whatever is the matter with you guys
Reply

#9
(03-21-2013, 16:43)kokole Wrote: So everyone's making plugin addons now?

No, i just was doing some boring stuff, because i was bored.
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#10
I said i was joking, at least 3 times. But if you wanna play that game, fine.
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Making an apocalyptic themed Minecraft map AZUMIKKEL 54 29,083 08-31-2013, 02:54
Last Post: AZUMIKKEL
  Making a Heli's angles match my angles? akillj 1 2,722 06-16-2013, 15:01
Last Post: Yamato
  Making a harrier crash into the map? akillj 6 4,934 06-09-2013, 05:57
Last Post: akillj
Brick Lesson 3: Making game in C++ Nekochan 2 3,562 06-03-2013, 15:25
Last Post: Nekochan
  Making a gametype multi-rounded? DidUknowiPwn 6 4,624 04-22-2013, 22:14
Last Post: Pozzuh
Rainbow Lesson 1: Making game in C++ Nekochan 6 5,249 02-04-2013, 15:27
Last Post: Nekochan
Rainbow Lesson 2: Making game in C++ Nekochan 1 2,750 02-04-2013, 15:14
Last Post: Ich1994
  W@W: Making player spawn with a custom default class. koil 9 5,452 01-13-2013, 12:10
Last Post: koil
  Glass house-machine gun Stocker 0 1,587 12-25-2012, 07:08
Last Post: Stocker
  [Tutorial] Making A Simple Calculator! Ivankec 4 8,778 12-14-2012, 19:22
Last Post: Gam3rr0rZ

Forum Jump:


Users browsing this thread:
3 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.