-
1 Attachment(s)
Windows Vista & 7 Glass Effect
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
http://www.vbforums.com/attachment.p...1&d=1273288521
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)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class
Good Luck :wave:
-
Re: Windows Vista & 7 Glass Effect
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
-
Re: Windows Vista & 7 Glass Effect
It looks great, but I don't know how useful it is, because control on it don't look that great...
http://i42.tinypic.com/rsa2w8.png
Is there nothing we can do about this?
-
Re: Windows Vista & 7 Glass Effect
Quote:
Originally Posted by JuggaloBrotha
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
Quote:
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.
-
Re: Windows Vista & 7 Glass Effect
Quote:
Originally Posted by
Pc_Not_Mac
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
-
Re: Windows Vista & 7 Glass Effect
I believe there is a error in
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
Error message
Quote:
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 :)
-
Re: Windows Vista & 7 Glass Effect
Here's the code I have, it works fine on Win7 x64
Code:
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)
-
Re: Windows Vista & 7 Glass Effect
I will try to fix that bug this week :wave:
-
Re: Windows Vista & 7 Glass Effect
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.
-
Re: Windows Vista & 7 Glass Effect
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 :>
-
Re: Windows Vista & 7 Glass Effect
Hello, i get an error saying that this dll dwmapi.dll cannot be found!
Am using winxp sp2 with vs2005 installed
-
Re: Windows Vista & 7 Glass Effect
Quote:
Originally Posted by
coolcurrent4u
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
-
Re: Windows Vista & 7 Glass Effect
can i just copy this dll into my system!
Please send me the dll
Thanks
-
Re: Windows Vista & 7 Glass Effect
Quote:
Originally Posted by
coolcurrent4u
can i just copy this dll into my system!
Please send me the dll
Thanks
You can, but you'll need all the other dll's too, which means you'll need to turn XP into Vista, Win7 or Server 2008 for the other dll's to work
-
Re: Windows Vista & 7 Glass Effect
That is frekin awesome! Mind if i use it in one of my projects?
-
Re: Windows Vista & 7 Glass Effect
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. :)
-
Re: Windows Vista & 7 Glass Effect
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
http://i45.tinypic.com/jubjf8.png
-
Re: Windows Vista & 7 Glass Effect
Quote:
Originally Posted by FunkyFreddo
That is freaking awesome! Mind if i use it in one of my projects?
Yea, You can use it in your projects.
Its all about code and not money;)
Just make sure you add some rep :)
-
Re: Windows Vista & 7 Glass Effect
Quote:
Originally Posted by
FunkyFreddo
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
http://www.vbforums.com/images/ieimages/2010/05/1.png
Nice :) good to see someone not going overboard with the glass effect and actually making a sensible use out of it.
For anyone wanting to do the same thing in WPF, here's an MS article on it (it is ever so slightly different to doing it for a winforms app) : http://msdn.microsoft.com/en-us/library/ms748975.aspx
-
Re: Windows Vista & 7 Glass Effect
Thanks xD its a pretty cool code snippet ^_^
-
Re: Windows Vista & 7 Glass Effect
Quote:
Originally Posted by
FunkyFreddo
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
http://www.vbforums.com/images/ieimages/2010/05/1.png
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 ..."
-
Re: Windows Vista & 7 Glass Effect
Mine says that is not declared or something. What shall i do?
-
Re: Windows Vista & 7 Glass Effect
-
Re: Windows Vista & 7 Glass Effect
Quote:
Originally Posted by
Pc_Not_Mac
Can you post the code.
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})
End If
Else
'ToDo: Turn it off
End If
End Sub
-
Re: Windows Vista & 7 Glass Effect
I need to spend some time and fix the many bugs :)
-
Re: Windows Vista & 7 Glass Effect
Quote:
Originally Posted by
Pc_Not_Mac
I need to spend some time and fix the many bugs :)
That has nothing to do with this... but okay.
-
Re: Windows Vista & 7 Glass Effect
Quote:
Originally Posted by
Emcrank
Mine says that
is not declared or something. What shall i do?
That's because you copied it from my post, but you didn't copy the entire code...
Quote:
Originally Posted by
Pc_Not_Mac
Can you post the code.
See my post waaay at the top.
Quote:
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
Quote:
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.
-
Re: Windows Vista & 7 Glass Effect
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 .
-
Re: Windows Vista & 7 Glass Effect
Quote:
Originally Posted by
NickThissen
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 :D) 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)
-
Re: Windows Vista & 7 Glass Effect
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 ;)
-
Re: Windows Vista & 7 Glass Effect
lol good old ClearType... causes more problems than its worth if you ask me!