[Mono-winforms-list] Window Capture

Miguel de Icaza miguel at ximian.com
Mon Oct 24 14:14:51 EDT 2005


Hello,

> I've recently found a way to get a window capture with C# on the .NET
> 1.1 Framework using Message class and WndProc method. While on Windows
> it returns me the bitmap of the window, with Mono on Linux, I'm just
> getting an empty bitmap (black bitmap, no window drawing). Is it the
> normal behavior ?

As I explained to you before, Managed.Windows.Forms only implements the
necessary messages required to support its own widgets and not every
possible windows message.

This message is not necessary for Windows.Forms to work, so it has not
been implemented. 

Although this could be implemented, it is not really a priority for us.
This is one of those situations where someone who has enough interest
will have to provide a patch if they want to get the functionality.

Miguel.

> the following source code is a click on a button on a form.
> 
> ## CODE ##
> 
>                 Bitmap inter = new Bitmap(this.Width, this.Height); 
>                 Graphics gfxInter = Graphics.FromImage(inter); 
>                 IntPtr hInter = gfxInter.GetHdc(); 
>  
>                 // Complete Window Capture 
>                 Message msg = new Message(); 
>                 msg.Msg = WM_PRINT; 
>                 msg.HWnd = this.Handle; 
>                 msg.WParam = hInter; 
>                 msg.LParam = new IntPtr(PRF_CLIENT | PRF_CHILDREN |
> PRF_NONCLIENT | PRF_ERASEBKGND); 
>                 this.WndProc(ref msg); 
>  
>                 gfxInter.ReleaseHdc(hInter); 
>                 gfxInter.Dispose();
> 
>                 inter.Save("test.jpg", ImageFormat.Jpeg); 
> 
> ## CODE ##
> _______________________________________________
> Mono-winforms-list maillist  -  Mono-winforms-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-winforms-list
-- 
Miguel de Icaza <miguel at ximian.com>


More information about the Mono-winforms-list mailing list