Cheers though it says 'InitializeComponent' is not declared:
Any suggestions?Code:Imports System.Data Imports System.Drawing Imports System.Text Imports System.Windows.Forms Imports System.Runtime.InteropServices Namespace GlassTest Public Class Form1 Inherits Form ' Import functions from dwmapi.dll - get this info from the sdk dwmapi.h <DllImport("dwmapi.dll", CharSet:=CharSet.Auto)> _ Public Shared Sub DwmExtendFrameIntoClientArea(ByVal hWnd As System.IntPtr, ByRef pMargins As Margins) End Sub <DllImport("dwmapi.dll", CharSet:=CharSet.Auto)> _ Public Shared Sub DwmIsCompositionEnabled(ByRef IsIt As Boolean) End Sub ' Create the brush that'll work around the Alpha transparency issue Private DWMFrame As SolidBrush = New SolidBrush(Color.Black) ' Define the Margins struct - get this from dwmapi.h Public Structure Margins Public Left As Integer Public Right As Integer Public Top As Integer Public Bottom As Integer End Structure ' Create an instance of the Margins struct for use in our form Private inset As Margins = New Margins Public Sub New() InitializeComponent() AddHandler Me.Paint, AddressOf Me.Form1_Paint ' Set the Margins to their default values inset.Top = 40 inset.Left = 0 inset.Right = 0 inset.Bottom = 0 ' Check if DWM is enabled. This is a pretty stupid way to check, since it requires dwmapi.dll to be present anyway... Dim isit As Boolean = False DwmIsCompositionEnabled(isit) If isit Then ' If DWM is enabled, call the function that gives us glass, passing a reference to our inset Margins DwmExtendFrameIntoClientArea(Me.Handle, inset) Else ' If DWM isn't enabled, shout it out MessageBox.Show("DWM isn't enabled") End If End Sub ' We need to override the Paint event as well as call the glass function. This is because of WindowsForms and Alpha-blending... Private Sub Form1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) e.Graphics.FillRectangle(DWMFrame, 0, 0, Width, inset.Top) e.Graphics.FillRectangle(DWMFrame, 0, 0, inset.Left, Height) ' Note the numbers ( -14, -34) are just trial-and-error values, used to fix the glass... try omitting them, you'll get the idea. e.Graphics.FillRectangle(DWMFrame, Width - inset.Right - 14, 0, inset.Right, Height) e.Graphics.FillRectangle(DWMFrame, 0, Height - inset.Bottom - 34, Width, inset.Bottom) End Sub End Class End Namespace




Reply With Quote