C# Winform 獲取控件在屏幕上的坐標


        private void CaptureJpeg()
        {
            var catchBmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            var g = Graphics.FromImage(catchBmp);
            //轉換成控件在屏幕上的坐標
            var screenPoint = PointToScreen(pictureBox1.Location);
            //拷貝屏幕區域到Bitmap
            g.CopyFromScreen(screenPoint, new Point(0, 0), new Size(pictureBox1.Width, pictureBox1.Height));
            //存文件
            catchBmp.Save(string.Format(@"D:\image\{0}.jpg",MAC));
        }

  var screenPoint = PointToScreen(pictureBox1.Location);


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM