I have c# windows 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!!!
That's my initial guess, but have to test it.
Restablish button.
This is pretty easy to do. Each control on the form has a Size and a Location property, which you can use to instantiate a new Rectangle, like so:
To get a Bitmap that contains the portion of the background image located behind the control, you first create a Bitmap of the proper dimensions:
You then create a Graphics object for the new Bitmap, and use that object's DrawImage method to copy a portion of the background image:
This will leave you with the new Bitmap (bmp) containing the portion of the background image underneath that control.
Sorry I can't be more specific in the code - I'm at a public terminal. But the intellisense info will tell you what you need to pass in for the DrawImage method.