views:

186

answers:

1

I have c# form which have several controls on it, part of the controls are located one on another. I want a function that will take for input a control from the form and will return the image that has to be behind the control. for ex: if the form has backgroundimage and contains a button on it - if I'll run this function I'll got the part of backgroundimage that located behind the button. any Idea - and code?

H-E-L-P!!!

+1  A: 

It may be simpler to use an image map http://www.echoecho.com/htmllinks07.htm You can create your links using Page.ClientScript.GetCallback...

Edit: Winforms solution

This takes the background image of 'this' which you can change to your form object and copies the whatever is at the same position and size of your button to a bitmap object.

Graphics objGraphics = Graphics.FromImage(this.BackgroundImage);
Bitmap objBitmap = new Bitmap(button1.Size.Width, button1.Size.Height);
objGraphics.DrawImage(bitmap, new Point(0, 0), new Rectangle(button1.Location, button1.Size), GraphicsUnit.Pixel);
Stephen lacy
It's not a web page, and it is not answering my Question:-(
Golan
added winforms solution
Stephen lacy