Try placing the following control class on a form in a new project:
--- CODE START ---
Imports System.Drawing.Drawing2D
Public Class ShapedPanel
Inherits System.Windows.Forms.Panel
Public Sub New()
MyBase.New()
ChangeControlRegion()
End Sub
Private Sub ChangeControlRegion()
Dim regionPath As GraphicsPath = GetControlShapePath()
Dim newRegion As System.Drawing.Region = New
System.Drawing.Region(regionPath)
Me.Region = newRegion
End Sub
Private Function GetControlShapePath() As GraphicsPath
Dim points(7) As Point
Dim types(7) As Byte
Dim result As GraphicsPath
Dim h As Integer = Me.Height
Dim w As Integer = Me.Width
Dim i As Integer
points(0) = New Point(1, 0)
points(1) = New Point(w - 1, 0)
points(2) = New Point(w, 1)
points(3) = New Point(w, h - 1)
points(4) = New Point(w - 1, h)
points(5) = New Point(1, h)
points(6) = New Point(0, h - 1)
points(7) = New Point(0, 1)
For i = 0 To 7
types(i) = CByte(PathPointType.Line)
Next i
result = New GraphicsPath(points, types)
Return result
End Function
End Class
--- CODE END ---
This panel should be drawn with a single pixel out of each of the four
corners. However, only the upper left corner pixel will be missing. Tests
I have done lead me to believe that the rightmost column and bottommost row
of pixels are not included in the region for some reason.
- Don
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:OD**************@TK2MSFTNGP15.phx.gbl...
Post some code to reproduce this effect please.
--
Bob Powell [MVP]
Visual C#, System.Drawing