hello friends,
how can i design a region in vb.net form(windows application), such that when i click any point inside a region a new page opens.
my problem is that the region which i want to define through it is very complex..its a combination of a rectangle and another shape.
thanks for your help:)

Member Avatar for Unhnd_Exception

Create the region with a GraphicsPath

Dim GraphicsPath As New Drawing2D.GraphicsPath(Drawing2D.FillMode.Winding)
   GraphicsPath.AddRectangle(New Rectangle(10, 10, 110, 110))
   GraphicsPath.AddEllipse(New Rectangle(50, 50, 100, 100))

   Me.Region = New Region(GraphicsPath)
Member Avatar for Unhnd_Exception

I may have read your post wrong.

This might be more of what your looking for.

Public Class Form1

    Private GraphicsPath As Drawing2D.GraphicsPath

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        GraphicsPath = New Drawing2D.GraphicsPath(Drawing2D.FillMode.Winding)
        GraphicsPath.AddRectangle(New Rectangle(10, 10, 110, 110))
        GraphicsPath.AddEllipse(New Rectangle(50, 50, 100, 100))

    End Sub

    Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
        If GraphicsPath.IsVisible(e.X, e.Y) Then
            MsgBox("Open a form")
        End If
    End Sub

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        e.Graphics.DrawPath(Pens.Black, GraphicsPath)
    End Sub

End Class

thanx for the post...
what if i wanted a unique region and not these predefined regions.

Member Avatar for Unhnd_Exception

The GraphicsPath has 14 Add methods. You say you want to create a region that is made up of a rectangle and another shape. What is the other Shape?

------------------------|
|
|
|-------------------------------------------------------
|
|
|
|
--------------------------------------------------------------------------------

Member Avatar for Unhnd_Exception

Not exactly sure what that is. If that is supposed to be a solid area then you can create a polygon by defining the points.

Top Left Corner 0,0
Top Right Corner 50,0
Middle Right Corner 100,25
Bottom Right Corner 125,100
Bottom Left Corner 0,100

Put those points into a Point array and use the AddPolygon method of the Graphics Path.

So Something Like:

Dim CustomPolygon(4) as Point

CustomPolygon(0) = new point(0,0)
CustomPolygon(1) = new point(50,0)
.......

GraphicsPath.AddPolygon(CustomPolygon)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.