2011-03-20 4 views

답변

2

제대로 작동하려면 몇 가지 작업을 수행해야합니다. 먼저 OnLoad() 메서드가 실행될 때까지 기다리는 것이 중요합니다. 그래야만 창문이 얼마나 큰지 알 수 있습니다. 사용자가 다른 DPI에서 비디오 어댑터를 실행하면 다른 컴퓨터의 디자인 크기가되지 않습니다. 테두리와 캡션을 제거해야하며 창에 모양을 지정할 때 더 이상 잘 작동하지 않습니다. 그들이하는 일을 다시 구현하는 것은 당신에게 달려 있습니다. 최소한 사용자가 여전히 창을 이동하도록 허용하고 싶을 것입니다.

이 작업을 수행 샘플 양식 : 자신의 윈도우 크롬을 구현하는 출발점으로

Public Class Form1 
    Public Sub New() 
     InitializeComponent() 
     Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None 
     Me.DoubleBuffered = True 
    End Sub 

    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs) 
     '' Set window shape 
     Using path As New System.Drawing.Drawing2D.GraphicsPath 
      path.AddEllipse(0, 0, Me.ClientSize.Width, Me.ClientSize.Height) 
      Me.Region = New Region(path) 
     End Using 
     MyBase.OnLoad(e) 
    End Sub 

    Private Const WM_NCHITTEST As Integer = &H84 
    Private Const HTCLIENT As Integer = 1 
    Private Const HTCAPTION As Integer = 2 
    Private Const CaptionHeight As Integer = 30 

    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) 
     MyBase.WndProc(m) 
     '' Detect clicks at top of window to allow it to be moved 
     If m.Msg = &H84 AndAlso m.Result.ToInt32() = HTCLIENT Then 
      Dim pos As Point = New Point(m.LParam.ToInt32()) 
      pos = Me.PointToClient(pos) 
      If pos.Y < CaptionHeight Then m.Result = CType(HTCAPTION, IntPtr) 
     End If 
    End Sub 

    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) 
     '' Draw a simple caption 
     e.Graphics.FillRectangle(Brushes.Blue, 0, 0, Me.ClientSize.Width, CaptionHeight) 
     MyBase.OnPaint(e) 
    End Sub 
End Class 

사용이. 사용자가 창을 닫을 수있는 글리프를 추가하고 싶을 것입니다. BackgroundImage 속성은 윈도우에 '텍스처'를 부여하는 좋은 방법입니다. 또는 OnPaint()를 수정하여 자신 만의 그림을 그릴 수도 있습니다.

3

양식의 Region 속성을 설정할 수 있습니다.

원형 영역을 만들려면 GraphicsPath을 만들고 AddEllipse을 호출 한 다음 Region 생성자로 전달합니다.

1

는 양식에 이러한 속성을 설정

1. BackgroundImage = your_Image   ' image of shape you want 
2. BackColor  = Outside_Area_Color ' color of outside area of image 
3. FormBorderStyle = None     ' to hide border and TitleBar of form 
4. TransparentKey = Same_as_BackColor 
관련 문제