The glass effect was the reason why i got Microsoft Windows Vista.
It looks very cool.
In general Microsoft has a better GUI then Apple Mac OSX 10.6 or 10.7 i lost track.
But Windows 7 has to be the best OS\GUI in 2009 - 2010.
With this little code that i have typed up on my typewriter
your program can look like Windows Explore etc...
Requirements
Windows 7 or Vista
Preview
Code
Vb.net Code:
Imports System.Runtime.InteropServices
Public Class Form1
<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> Public Structure Side
Public Left As Integer
Public Right As Integer
Public Top As Integer
Public Buttom As Integer
End Structure
<Runtime.InteropServices.DllImport("dwmapi.dll")> Public Shared Function DwmExtendFrameIntoClientArea(ByVal hWnd As IntPtr, ByRef pMarinset As Side) As Integer
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Me.BackColor = Color.Black 'It has to be black
Dim side As Side = New Side
side.Left = -1
side.Right = -1
side.Top = -1
side.Buttom = -1
Dim result As Integer = DwmExtendFrameIntoClientArea(Me.Handle, side)
Now that is just plain awesome, especially with how easy it is
Any idea to how it runs on an XP system?
Edit: It'll crash in the form load event but that's easy to work around since you can do an OSVersion.Major check before setting the Vista/Win7 api call, which means you're able to use a different theme instead for the older systems
This is pretty slick
Last edited by JuggaloBrotha; May 8th, 2010 at 01:55 AM.
Currently using VS 2015 Enterprise on Win10 Enterprise x64.
Now that is just plain awesome, especially with how easy it is
Any idea to how it runs on an XP system?
Edit: It'll crash in the form load event but that's easy to work around since you can do an OSVersion.Major check before setting the Vista/Win7 api call, which means you're able to use a different theme instead for the older systems
This is pretty slick
I fixed up the code.
So now it will check the users OS before loading the glass.
I mean you can try to download dwmapi.dll and place it to Windows32 Folder but i do not think that it will work.
=Vb.net Code:
Imports System.Runtime.InteropServices
Public Class Form1
<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> Public Structure Side
Public Left As Integer
Public Right As Integer
Public Top As Integer
Public Buttom As Integer
End Structure
<Runtime.InteropServices.DllImport("dwmapi.dll")> Public Shared Function DwmExtendFrameIntoClientArea(ByVal hWnd As IntPtr, ByRef pMarinset As Side) As Integer
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strr As String = UCase(My.Computer.Info.OSFullName)
If strr.Contains("VISTA") Or strr.Contains("WINDOWS 7") Then
Try
Me.BackColor = Color.Black 'It has to be black
Dim side As Side = New Side
side.Left = -1
side.Right = -1
side.Top = -1
side.Buttom = -1
Dim result As Integer = DwmExtendFrameIntoClientArea(Me.Handle, side)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Else
MsgBox("Your OS " & My.Computer.Info.OSFullName.ToString & " Is Supported With Glass.", MsgBoxStyle.Exclamation, "Error Loading dwmapi.dll")
End If
End Sub
End Class
Originally Posted by NickThissen
It looks great, but I don't know how useful it is, because control on it don't look that great...
If you were to drag that over a black picture it would look normal.
But i know that is a bug and i will try to fix it.
I fixed up the code.
So now it will check the users OS before loading the glass.
I mean you can try to download dwmapi.dll and place it to Windows32 Folder but i do not think that it will work.
=Vb.net Code:
Imports System.Runtime.InteropServices
Public Class Form1
<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> Public Structure Side
Public Left As Integer
Public Right As Integer
Public Top As Integer
Public Buttom As Integer
End Structure
<Runtime.InteropServices.DllImport("dwmapi.dll")> Public Shared Function DwmExtendFrameIntoClientArea(ByVal hWnd As IntPtr, ByRef pMarinset As Side) As Integer
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strr As String = UCase(My.Computer.Info.OSFullName)
If strr.Contains("VISTA") Or strr.Contains("WINDOWS 7") Then
Try
Me.BackColor = Color.Black 'It has to be black
Dim side As Side = New Side
side.Left = -1
side.Right = -1
side.Top = -1
side.Buttom = -1
Dim result As Integer = DwmExtendFrameIntoClientArea(Me.Handle, side)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Else
MsgBox("Your OS " & My.Computer.Info.OSFullName.ToString & " Is Supported With Glass.", MsgBoxStyle.Exclamation, "Error Loading dwmapi.dll")
End If
End Sub
End Class
Actually I would use the version number to do the OS check personally:
Code:
Imports System.Runtime.InteropServices
Public Class Form1
<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> Public Structure Side
Public Left As Integer
Public Right As Integer
Public Top As Integer
Public Buttom As Integer
End Structure
<Runtime.InteropServices.DllImport("dwmapi.dll")> Public Shared Function DwmExtendFrameIntoClientArea(ByVal hWnd As IntPtr, ByRef pMarinset As Side) As Integer
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Environment.OSVersion.Platform = PlatformID.Win32NT AndAlso Environment.OSVersion.Version.Major >= 6I Then
Me.BackColor = Color.Blue 'It doesn't have to be black, Win7 supports all colors
DwmExtendFrameIntoClientArea(Me.Handle, New Side With {.Left = -1I, .Right = -1I, .Top = -1I, .Buttom = -1I})
End If
End Sub
End Class
Last edited by JuggaloBrotha; May 8th, 2010 at 04:37 PM.
Currently using VS 2015 Enterprise on Win10 Enterprise x64.
Imports System.Runtime.InteropServices
Public Class Form1
<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> Public Structure Side
Public Left As Integer
Public Right As Integer
Public Top As Integer
Public Buttom As Integer
End Structure
<Runtime.InteropServices.DllImport("dwmapi.dll")> Public Shared Function DwmExtendFrameIntoClientArea(ByVal hWnd As IntPtr, ByRef pMarinset As Side) As Integer
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Environment.OSVersion.Platform = PlatformID.Win32NT AndAlso Environment.OSVersion.Version.Major >= 6I Then
Me.BackColor = Color.Blue 'It doesn't have to be black, Win7 supports all colors
DwmExtendFrameIntoClientArea(Me.Handle, New Side With {.Left = -1I, .Right = -1I, .Top = -1I, .Buttom = -1I})
End If
End Sub
End Class
Error message
Error 1 'System.Runtime.InteropServices.DllImportAttribute' cannot be applied to a Sub, Function, or Operator with a non-empty body. C:\Users\Bill Gates\Documents\Visual Studio 2008\Projects\Glass Effect\Glass Effect\Form1.vb 11 78 Glass Effect
I might be wrong because i did not take time to look over it
Imports System.ComponentModel
Imports System.Runtime.InteropServices
<DebuggerStepThrough()> _
Public Class Win7Form
Inherits System.Windows.Forms.Form
<StructLayout(LayoutKind.Sequential)> _
Public Structure Side : Public Left, Right, Top, Bottom As Integer : End Structure
<DllImport("dwmapi.dll")> _
Public Shared Function DwmExtendFrameIntoClientArea(ByVal hWnd As IntPtr, ByRef pMarinset As Side) As Integer
End Function
#Region " Variables "
#End Region
#Region " Constructor, Dispose "
Public Sub New()
MyBase.New()
MyBase.AutoScaleMode = AutoScaleMode.Font
Call DoWin7(True)
End Sub
<DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing Then
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
#End Region
Private Sub DoWin7(ByVal Enabled As Boolean)
If Enabled Then
If Environment.OSVersion.Platform = PlatformID.Win32NT AndAlso Environment.OSVersion.Version.Major >= 6I Then
Me.BackColor = Color.Black 'It has to be black
DwmExtendFrameIntoClientArea(Me.Handle, New Side With {.Left = -1I, .Right = -1I, .Top = -1I, .Bottom = -1I})
End If
Else
'ToDo: Turn it off
End If
End Sub
'ToDo: Create Enabled property
End Class
I'm making it a user control, that inherits the FW's Form then my actual forms simply inherit this control and has the Areo Glass automatically (yet still works on XP and older as a standard form)
Currently using VS 2015 Enterprise on Win10 Enterprise x64.
I have removed several (far too many) off-topic posts.
While there are vague similarities between the code above and the code here, they are both reasonable implementations based on the actual documentation for DwmExtendFrameIntoClientArea - and it is hard to see how two different implementations could be any less similar than they are.
i have problem i would like my text/webbrowser on screen like menustips etc.... so the text is still black not transparent or any colour i choose the text to be how would i do this , but what you have done soo far is awesome just that little hitch i want you to fix some how thanks
plus webbrowser webpage is transparent i want that back to normal but i want this feature :>
Last edited by pillhead2007; May 16th, 2010 at 03:30 PM.
Hello, i get an error saying that this dll dwmapi.dll cannot be found!
Am using winxp sp2 with vs2005 installed
That would be because XP doesn't have Areo Glass so it wont work. We've also got the OS check so it'll be a normal form on XP and older computers, but be glass on Vista and newer computers automatically
Currently using VS 2015 Enterprise on Win10 Enterprise x64.
You can use any of the code on this site in your projects, unless there is something with the code that explicitly says otherwise - and there isn't anything like that here.
Thats pretty cool, ive already implimented it into my first project! This forum is pretty cool, i've been looking for a place to get support and share with other people using VB, im very new to it lol. Heres how i've put it in my project :P
Thats pretty cool, ive already implimented it into my first project! This forum is pretty cool, i've been looking for a place to get support and share with other people using VB, im very new to it lol. Heres how i've put it in my project :P
Nice good to see someone not going overboard with the glass effect and actually making a sensible use out of it.
Thats pretty cool, ive already implimented it into my first project! This forum is pretty cool, i've been looking for a place to get support and share with other people using VB, im very new to it lol. Heres how i've put it in my project :P
It looks like you were trying to do "Designed & Coded By ..." If you want to use an ampersand then you would have to set your text property to "Designed && Coded By ..."
He probably copy and pasted the code from post #7, which references the Win7 sub that JuggaloBrotha created. Which means he didn't copy that sub.
The error he said he received was "not declared", which means that whatever Win7 was, it wasn't there. A quick CTRL+F located Win7 and I assumed as much from there =/
VB.NET Code:
Private Sub DoWin7(ByVal Enabled As Boolean)
If Enabled Then
If Environment.OSVersion.Platform = PlatformID.Win32NT AndAlso Environment.OSVersion.Version.Major >= 6I Then
Me.BackColor = Color.Black 'It has to be black
DwmExtendFrameIntoClientArea(Me.Handle, New Side With {.Left = -1I, .Right = -1I, .Top = -1I, .Bottom = -1I})
That's because you copied it from my post, but you didn't copy the entire code...
Originally Posted by Pc_Not_Mac
Can you post the code.
See my post waaay at the top.
Originally Posted by weirddemon
He probably copy and pasted the code from post #7, which references the Win7 sub that JuggaloBrotha created. Which means he didn't copy that sub.
The error he said he received was "not declared", which means that whatever Win7 was, it wasn't there. A quick CTRL+F located Win7 and I assumed as much from there =/
Yep
Originally Posted by Pc_Not_Mac
I need to spend some time and fix the many bugs
I'd kind of forgotten about it since it's not a control I'm thinking of using, I can finish what my code had started sometime later this weekend.
Currently using VS 2015 Enterprise on Win10 Enterprise x64.
This code is pretty cool.
You can use it as the background of toolbox or like menu option box thing or wizard.
If you use it for a word editor the application might look like cr...p .
It looks great, but I don't know how useful it is, because control on it don't look that great...
Is there nothing we can do about this?
Nick: I have heard of ways to prevent it from doing that, but I don't know exactly what they are. I think it might have to do with Owner/Custom Drawing and such. You might try contacting the folks at Paint.NET, as they have a few buttons on glass.(If they reply, or you figure it out, please post it ) Personally, I use a slightly modified version of a 'Glass effects extender library' I found on CodeProject. You may be able to learn a couple things about Glass from that (I hope that this is not taking away from your audience, Pc_Not_Mac)
If I helped you in any way, please add to my reputation
Okay, I have actually found out a way around the "horrible text" problem. For each control you need to "fix", subclass it and add this:
Code:
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
e.Graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
MyBase.OnPaint(e)
End Sub
Apparently ClearType causes the problem. You can also set the TextRenderingHint to AntiAliasGridFit or SingleBitPerPixel. SingleBitPerPixelGridFit makes the text disappear and ClearTypeGridFit is the default which you don't want.
P.S. Sorry for bumping up an old thread but I'm sure at least some people still want this
Last edited by minitech; Feb 9th, 2011 at 09:56 PM.