Link to home
Start Free TrialLog in
Avatar of Micki-Weaver
Micki-Weaver

asked on

make a hole in a form??

how do I creat a hole in a form??
Avatar of marklorenz
marklorenz
Flag of United States of America image

Not sure what you're asking - do you mean an "empty" spot when rendered?
Avatar of Micki-Weaver
Micki-Weaver

ASKER

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

a hole in a form
Avatar of Bob Learned
If you set the TransparencyKey, and have a region that is a that color, there will be a hole bored through the form.

Bob
I can't allways count on having control of the TransparencyKey, or form backcolor, any other ways??
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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;
            gp.AddEllipse(RectangleIN);

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