Go Premium for a chance to win a PS4. Enter to Win


make a hole in a form??

Posted on 2007-08-16
Medium Priority
Last Modified: 2013-11-07
how do I creat a hole in a form??
Question by:Micki-Weaver
LVL 12

Expert Comment

ID: 19713863
Not sure what you're asking - do you mean an "empty" spot when rendered?

Author Comment

ID: 19713960
.Net, C# if you would but VB is ok

a hole in a form
LVL 96

Expert Comment

by:Bob Learned
ID: 19713988
If you set the TransparencyKey, and have a region that is a that color, there will be a hole bored through the form.

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks


Author Comment

ID: 19717796
I can't allways count on having control of the TransparencyKey, or form backcolor, any other ways??
LVL 86

Accepted Solution

Mike Tomlinson earned 1000 total points
ID: 19718320
"but VB is ok"

Here is a hard coded "hole" in a form...

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim gp As New System.Drawing.Drawing2D.GraphicsPath

        ' start with a rectangle that represents the whole form
        gp.AddRectangle(New Rectangle(0, 0, Me.Width, Me.Height))

        ' add an ellipse...which is removed from the rectangle above
        Dim w As Integer = Me.Width / 4
        Dim h As Integer = Me.Height / 4
        gp.AddEllipse(New Rectangle(w, h, w * 2, h * 2))

        ' create a Region from the GraphicsPath and set it...
        Me.Region = New Region(gp)
    End Sub

End Class

Author Comment

ID: 19720176
a upgrade and in C#

        public static void MakeHole(System.Windows.Forms.Form FormIN, System.Drawing.Rectangle RectangleIN)
            System.Drawing.Size SizeIN = FormIN.Size;
            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();

            // start with a rectangle that represents the whole form
            gp.AddRectangle(new Rectangle(0, 0, SizeIN.Width, SizeIN.Height));

            // add an ellipse...which is removed from the rectangle above
            int w = FormIN.Width / 4;
            int h = FormIN.Height / 4;

            // create a Region from the GraphicsPath and set it...
            FormIN.Region = new Region(gp);

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question