I want to get control coordinates on mouse Clicked. Let's say after running my app user click on Visual Studio File Menu. So, I want to get File Menu control Coordinates. This is the code I have tried. I am not successful getting it. Note: This is windform application.
if (ClientRectangle.Contains(PointToClient(Control.MousePosition)))
{
// MessageBox.Show("Width:" + ClientRectangle.Width.ToString() + "--- Height: " + ClientRectangle.Height.ToString() + "---" + "X:" + ClientRectangle.X.ToString() + "--- Y: " + ClientRectangle.Y.ToString());
Point location = button1.PointToScreen(Point.Empty);
MessageBox.Show(location.X.ToString()+"---------"+location.Y.ToString()+"---------"+ location+ClientRectangle.Width.ToString()+"---------"+ClientRectangle.Height.ToString());
// Rectangle rect = new Rectangle(0, 0, 100, 100);
int with = ClientRectangle.Width;
int height = ClientRectangle.Height;
Bitmap bmp = new Bitmap((int)with, (int)height, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(bmp);
// g.CopyFromScreen(ClientRectangle.Left, ClientRectangle.Top, 50,50, bmp.Size, CopyPixelOperation.SourceCopy);
g.CopyFromScreen(location.X, location.Y, 0, 0, new Size(ClientRectangle.Width-30, ClientRectangle.Height-36));
bmp.Save(@"capture.jpg", ImageFormat.Jpeg)
}
Any Suggestion code will be much appreciated.