I have a problem to copy a picturebox at runtime that need the current position of the screen with respect to picturebox
In this line of code took the position of the picturebox but I need the position with respect to the screen. Is there any way we could do?
// gfxScreenshot.CopyFromScreen(pictureBox1.Bounds.X, pictureBox1.Bounds.Y, 0, 0, pictureBox1.Bounds.Size, CopyPixelOperation.SourceCopy);
if (saveScreenshot.ShowDialog() == DialogResult.OK)
{
bmpScreenshot = new Bitmap(pictureBox1.Bounds.Width, pictureBox1.Bounds.Height, PixelFormat.Format32bppArgb);
gfxScreenshot = Graphics.FromImage(bmpScreenshot);
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
bmpScreenshot.Save(saveScreenshot.FileName, ImageFormat.Png);
}
To get the screen coordinates of a position of the picture box itself, use:
To get the screen coordinates of a point within the picture box:
That will give you the screen coordinates of the position (10, 10) within the picture box.