954,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

click region

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:)

aadi_capri
Light Poster
40 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 


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)
Unhnd_Exception
Posting Pro
571 posts since Nov 2010
Reputation Points: 249
Solved Threads: 201
 


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
Unhnd_Exception
Posting Pro
571 posts since Nov 2010
Reputation Points: 249
Solved Threads: 201
 

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

aadi_capri
Light Poster
40 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 


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?

Unhnd_Exception
Posting Pro
571 posts since Nov 2010
Reputation Points: 249
Solved Threads: 201
 

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

aadi_capri
Light Poster
40 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 


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)
Unhnd_Exception
Posting Pro
571 posts since Nov 2010
Reputation Points: 249
Solved Threads: 201
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: