One of the most coolest features of Windows Vista/7 is its glass effect in Forms.
In this short tutorial I'll show you how to make your form entirely transparent. The difference is that by default Windows do transparency in title bar. But we can change that and apply the transparency to complete Form.
Here we go:
Create a new project.
Add this namespace:
Code:
Imports System.Runtime.InteropServices
Then add this:
Code:
'This will declare margins for transparency of our window...
<StructLayout(LayoutKind.Sequential)> _
Public Structure WinMargins
Public LWidth As Integer
Public THeight As Integer
Public RWidth As Integer
Public BHeight As Integer
End Structure
Then declare the following API:
Note: The following API is only present in Windows Vista /7
Code:
<DllImport("dwmapi.dll")> _
Public Shared Function DwmExtendFrameIntoClientArea(ByVal hWnd As IntPtr, ByRef pMarinset As WinMargins) As Integer
End Function
Now Double Click The Form and add the following code:
Code:
Dim margins As WinMargins = New WinMargins
'The value of -1 is used when you want to use full window as transparency...
Dim WM As WinMargins = New WinMargins
WM.LWidth = -1
WM.RWidth = -1
WM.THeight = -1
WM.BHeight = -1
'The handle of your window..
Dim handle As IntPtr = Me.Handle
' Finally call the API function by inputing window handle and your window margins ..
DwmExtendFrameIntoClientArea(handle, WM)
Note: Transparency will not turned on unless you change the Form's back color to Black.
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MyNewSub()
End Sub
Sub MyNewSub()
TransparencyKey = BackColor
End Sub
End Class
something like that?
You're welcome. If I get time I'll write some more tutorials because Aero API is very rich and offers many other great effects
And yes VB can do anything. All .NET languages are equivalently powerful
yo mang pm me back
Originally Posted by tremaster
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MyNewSub()
End Sub
Sub MyNewSub()
TransparencyKey = BackColor
End Sub
End Class
something like that?
No, buddy not like that. I think you didn't followed the tutorial. Plus I doubt that you are not using Vista/7.
Anyways tutorial is easy. Follow it and hopefully you will get the effect
Looks Great, thanks for sharing.
Sorry, im a newb to Visual Basic, and I don't understand most of this tutorial, you don't have to, but can you make this more newb friendly or make a video? Cause' I really wanna know how to do this. If you can't, its all good.
Thread Reopened, Credit to author added to post 1
While this thread might be repoened lets get a couple things straight:
1. It's is not our responsibility to make sure you credit your sources.
2. It is not right to claim others work as your own, in order to make urself look good.
There is nothing wrong with sharing a tutorial that you found interesting, preferably not from a rival site though, but if you want to link to MSDN, or even share some interesting snippets that is no big deal, but you can not just outright use someone else's work without even attempting to mention them.
wow it looks so cool but i cant get it to work (i think its cause i have XP)
I love this so much.
Probably going to use this for everything now.
Originally Posted by tempta43
I love this so much.
Probably going to use this for everything now.