# Has anyone used this glass code in VB.NET?



## Dark_Webster (Jun 6, 2009)

Like the title says:


```
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential)> _
Public Structure MARGINS
    Public cxLeftWidth As Integer
    Public cxRightWidth As Integer
    Public cyTopHeight As Integer
    Public cyBottomHeight As Integer
End Structure

Public Class Form 1
<DllImport("dwmapi.dll")> _
Public Shared Function DwmExtendFrameIntoClientArea(ByVal hWnd As IntPtr, ByRef pMarinset As MARGINS) As Integer
    End Function

Private Sub Form1_Load(......)
On Error Resume Next
        Dim margins As MARGINS = New MARGINS
        margins.cxLeftWidth = -1
        margins.cxRightWidth = -1
        margins.cyTopHeight = -1
        margins.cyBottomHeight = -1
        'set all the four value -1 to apply glass effect to the whole window
        'set your own value to make specific part of the window glassy.
        Dim hwnd As IntPtr = Me.Handle
        Dim result As Integer = DwmExtendFrameIntoClientArea(hwnd, margins)
End Sub
```

Has anyone used this code on some kind of app of yours? If so, did it integrate well with glass or not? I'm not being able to make it integrate well.


----------



## Lillebror (Jun 6, 2009)

You need to make your background black for that one to work.


----------



## FordGT90Concept (Jun 6, 2009)

What do you mean by "not being able to make it integrate well?"


----------



## Dark_Webster (Jun 6, 2009)

Lillebror said:


> You need to make your background black for that one to work.



Yes, I know that, but some objects become so badly integrated:







The labels look not so bad, but the one on the status bar becomes awful.


----------



## Lillebror (Jun 6, 2009)

You should try to find a new way to get the glass effect - cause its not that good, for general use.


----------



## Dark_Webster (Jun 6, 2009)

Lillebror said:


> You should try to find a new way to get the glass effect - cause its not that good, for general use.



So I should mess with the glass position to not to use all the window, only what I need right? I'm doing sorta that... so that the program doesn't feel weird.


----------



## Lillebror (Jun 6, 2009)

It would work in theory, yeah.


----------



## FordGT90Concept (Jun 7, 2009)

Just get an image that somewhat ressembles glass and turn the opacity of the form down to like 80%.


----------

