[ vb 2008 ] 투명창 예제 본문

[PL]/VB & VB.NET

[ vb 2008 ] 투명창 예제

객과 함께. 2010. 1. 6. 14:34

<Window x:Class="Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="314" Width="485" Name="Window1">
    <Grid></Grid>
</Window>


Imports System
Imports System.Windows.Interop
Imports System.Runtime.InteropServices

Public Class Window1

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

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

    Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
        on Error Resume Next

        Dim margins As MARGINS = New MARGINS

        Me.Title = "투명창 예제"

        margins.cxLeftWidth = -1
        margins.cxRightWidth = -1
        margins.cyTopHeight = -1
        margins.cyButtomheight = -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 = New WindowInteropHelper(Window1).Handle
        If Not hwnd = 0 Then
            Throw New InvalidProgramException("The Window must be shown before glass")
        End If
        Window1.Background = Brushes.Transparent
        HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent

        Dim result As Integer = DwmExtendFrameIntoClientArea(hwnd, margins)
    End Sub
End Clas

 

[ 실행 화면 ]

 

 

참고 사이트 :  dotnetmvp.tistory.com

              :  taedi.kr 

                MSDN 

'[PL] > VB & VB.NET' 카테고리의 다른 글

[ VB 2008 ] DrawLine 예제  (0) 2010.01.08
[ VB 2008 ]외부 프로그램 실행 하기........  (0) 2010.01.07
[ vb 2008 ] Calendar 예제  (0) 2010.01.05
[ vb 2008 ] Element:Shape (Line)  (0) 2010.01.05
[ vb 2008 ] Ellipse 예제  (0) 2010.01.05