Пример #1
0
        private void buttonCaputre_Click(object sender, EventArgs e)
        {
            this.Hide();
            Thread.Sleep(500);

            Image    img = new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height);
            Graphics g   = Graphics.FromImage(img);

            g.CopyFromScreen(new Point(0, 0), new Point(0, 0), Screen.AllScreens[0].Bounds.Size);

            ScreenForm snap = new ScreenForm();

            snap.BackgroundImage = img;

            if (snap.ShowDialog() == DialogResult.OK)
            {
                //获取RichTextBox控件中鼠标焦点的索引位置
                int startPosition = this.richTextBoxChat.SelectionStart;
                //从鼠标焦点处开始选中几个字符
                //this.richTextBoxMessage.SelectionLength = 2;
                //将图片粘贴到鼠标焦点位置(由于有选中2个字符,所以那2个字符会被图片覆盖)
                this.richTextBoxChat.Paste();
                Clipboard.Clear();
            }
            Thread.Sleep(300);
            this.Show();
        }
Пример #2
0
        private void buttonCaputre_Click(object sender, EventArgs e)
        {
            this.Hide();
            Thread.Sleep(500);

            Image img = new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height);
            Graphics g = Graphics.FromImage(img);
            g.CopyFromScreen(new Point(0, 0), new Point(0, 0), Screen.AllScreens[0].Bounds.Size);

            ScreenForm snap = new ScreenForm();
            snap.BackgroundImage = img;

            if (snap.ShowDialog() == DialogResult.OK)
            {
                //获取RichTextBox控件中鼠标焦点的索引位置
                int startPosition = this.richTextBoxChat.SelectionStart;
                //从鼠标焦点处开始选中几个字符
                //this.richTextBoxMessage.SelectionLength = 2;
                //将图片粘贴到鼠标焦点位置(由于有选中2个字符,所以那2个字符会被图片覆盖)
                this.richTextBoxChat.Paste();
                Clipboard.Clear();
            }
            Thread.Sleep(300);
            this.Show();
        }