Quote:
> In vb6 I was able to create a form with a shape of a polygon using
> some APIs.
> In vb.net the APIs can not be used because the property "handle" is
> not the same as "hWnd" and can not be casted. Can anyone tell me what
> to do?
You need to create a new Region and set that to be the region of your form.
. . .Here is an example:
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim grphSurface As Graphics
Dim grphPath As GraphicsPath = New GraphicsPath()
Dim rgnSurface As Region
Dim rectText As RectangleF
Dim fntText As Font
Dim XPoints1(3) As PointF
Dim XPoints2(3) As PointF
Me.BackColor = Color.Goldenrod
XPoints1(0) = New PointF(10, 0)
XPoints1(1) = New PointF(0, 10)
XPoints1(2) = New PointF(Me.Width - 10, Me.Height)
XPoints1(3) = New PointF(Me.Width, Me.Height - 10)
XPoints2(0) = New PointF(Me.Width - 10, 0)
XPoints2(1) = New PointF(Me.Width, 10)
XPoints2(2) = New PointF(10, Me.Height)
XPoints2(3) = New PointF(0, Me.Height - 10)
grphPath.AddEllipse(Me.ClientRectangle)
rgnSurface = New Region(grphPath)
Me.Region = rgnSurface
With Me.ClientRectangle
rectText = New RectangleF(.X + 3, .Height \ 3, .Width + 3,
.Height \ 2)
End With
fntText = New Font(Me.Font.FontFamily, 55, FontStyle.Bold)
grphSurface = Me.CreateGraphics
grphSurface.DrawEllipse(New Pen(Color.Black, 10),
Me.ClientRectangle)
grphSurface.FillPolygon(New SolidBrush(Color.Black), XPoints1)
grphSurface.FillPolygon(New SolidBrush(Color.Black), XPoints2)
grphSurface.DrawString("R R", fntText, New
SolidBrush(Color.Black), rectText)
fntText.Dispose()
grphSurface.Dispose()
grphPath.Dispose()
rgnSurface.Dispose()
End Sub
--
Jacob Grass
Microsoft .NET MVP
Check out http://windowsforms.net