DIGIT-ARC read-only archive · snapshot: July 23, 2026

CopyFromScreen method isn't affected by clipping region , why ??

3 posts · originally from https://geek.digit.in/community/threads/copyfromscreen-method-isnt-affected-by-clipping-region-why.98408/

pavilion
pavilion Original post #1
Sep 25, 2008 at 4:00 PM
I want to copy a portion of desktop screen and draw it on form (that portion can be in rectangular , elliptic or freeform shape ) , so I have to use a clipping region because the method just copy a rectangle portion from screen . Sound easy , I hope you understand
First I used APIs : SelectClipRgn and BitBlt , everything's done perfectly . Then I tried to make it in .NET way , use CopyFromScreen method and Graphics.SetClip . But it appear that the CopyFromScreen method isn't affected by clipping region . For example
Code:
 Graphics w = this.CreateGraphics;
w.SetClip(new Rectangle(0, 0, 100, 100);
w.CopyFromScreen(0, 0, 0, 0, new Size(500, 500));
You see, I copy a 500x500 rectangle from screen into a 100x100 clipping region , but the form still draw the 500x500 rectange ???
swatkat
swatkat #2
Oct 5, 2008 at 7:10 PM
I don't know anything related to .NET. But, Google lead me to this ;)
*www.dotnetcurry.com/ShowArticle.aspx?ID=117&AspxAutoDetectCookieSupport=1
Hope that helps....
pavilion
Oct 18, 2008 at 9:34 AM
Thanks ^^ but it's not exactly my situation , the tutorial in that link doesn't use clipping region