1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Has anyone used this glass code in VB.NET?

Discussion in 'Programming & Webmastering' started by Dark_Webster, Jun 6, 2009.

  1. Dark_Webster New Member

    Joined:
    Jul 29, 2007
    Messages:
    393 (0.15/day)
    Thanks Received:
    51
    Location:
    Portugal
    Like the title says:

    Code:
    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.
  2. Lillebror New Member

    Joined:
    Jul 28, 2007
    Messages:
    720 (0.28/day)
    Thanks Received:
    88
    Location:
    Denmark
    You need to make your background black for that one to work.
  3. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    13,414 (6.27/day)
    Thanks Received:
    3,393
    Location:
    IA, USA
    What do you mean by "not being able to make it integrate well?"
    Crunching for Team TPU
  4. Dark_Webster New Member

    Joined:
    Jul 29, 2007
    Messages:
    393 (0.15/day)
    Thanks Received:
    51
    Location:
    Portugal
    Yes, I know that, but some objects become so badly integrated:

    [​IMG]

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

    Joined:
    Jul 28, 2007
    Messages:
    720 (0.28/day)
    Thanks Received:
    88
    Location:
    Denmark
    You should try to find a new way to get the glass effect - cause its not that good, for general use.
  6. Dark_Webster New Member

    Joined:
    Jul 29, 2007
    Messages:
    393 (0.15/day)
    Thanks Received:
    51
    Location:
    Portugal
    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.
  7. Lillebror New Member

    Joined:
    Jul 28, 2007
    Messages:
    720 (0.28/day)
    Thanks Received:
    88
    Location:
    Denmark
    It would work in theory, yeah.
  8. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    13,414 (6.27/day)
    Thanks Received:
    3,393
    Location:
    IA, USA
    Just get an image that somewhat ressembles glass and turn the opacity of the form down to like 80%.
    Crunching for Team TPU

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page