2

I know this is maybe old subject. But I have to know about it in detailed explanation.

Thanks in advance.

I have below code snippet from here

 public static Image Snip() {
        var rc = Screen.PrimaryScreen.Bounds;
        using (Bitmap bmp = new Bitmap(rc.Width, rc.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb)) {
            using (Graphics gr = Graphics.FromImage(bmp))
                gr.CopyFromScreen(0, 0, 0, 0, bmp.Size);
            using (var snipper = new SnippingTool(bmp)) {
                if (snipper.ShowDialog() == DialogResult.OK) {
                    return snipper.Image;
                }
            }
            return null;
        }
    }

Now, what about on multiple screens? This code only shows based on primary screen. But I want to play capture on multiple screen bounds!

Community
  • 1
  • 1
kale
  • 21
  • 3
  • 1
    There is a link from that thread you linked to handle multiple monitors. It links to the following SO thread: http://stackoverflow.com/questions/4005910/make-net-snipping-tool-compatible-with-multiple-monitors – jpaugh78 Jun 06 '16 at 00:08
  • Link that you provided just shows the converted code for vb. I also tried it but I have no good result from there. – kale Jun 06 '16 at 00:14
  • Did you try the code that S_R linked in that thread? It's about the 4th post down. He links C# code and then how to call it. – jpaugh78 Jun 06 '16 at 00:18
  • Same result. One thing is blocked me but I still could not understand it. Thank you! If you show me some code from your side, it will be better then. – kale Jun 06 '16 at 21:00
  • I took his code and it works fine for me. I tossed it into a Visual Studio 2015 project. 1) click the button 2) drag your mouse to take the screenshot. 3) the screenshot is saved to your desktop. It seems you are limited to whichever monitor the form is on when you press the botton. https://www.dropbox.com/s/lfe6n9bhaxajr1p/Screenshots.zip?dl=0 – jpaugh78 Jun 07 '16 at 02:48
  • Thank you for your help. But as you mentioned in your comment, this only works on primary screen not for both dual monitor. Indeed what I meant is how I can solve this issue for both usage. Again thanks for your help. – kale Jun 07 '16 at 23:42
  • I messed around with the code and got it to work for two monitors. But you have to start drawing on the left monitor for some reason. Not sure what I have to change to get it to work so that you can start on either monitor. I can post the code I have now if you want. – jpaugh78 Jun 08 '16 at 00:49
  • It would be good if you can post the code! Thank you! – kale Jun 08 '16 at 22:28
  • Here is the version I modified. I have 3 monitors, and they are numbered oddly. So if you look at my code you want to mess with the `Screen currentScreen = Screen.AllScreens[1];` lines. So in this case, [1] was my left monitor. https://www.dropbox.com/s/fs5eeidyvna8amx/Screenshotsv2.zip?dl=0 – jpaugh78 Jun 08 '16 at 22:34

0 Answers0