GdPicture.NET.14
GdPicture14 Namespace / GdPictureImaging Class / CreateGdPictureImageFromHwnd Method / CreateGdPictureImageFromHwnd(IntPtr) Method
A Window Handle, as IntPtr value. This must be a top-level window or a child of a top level window.
Example





In This Topic
CreateGdPictureImageFromHwnd(IntPtr) Method
In This Topic
Creates a new GdPicture image from a window handle HWnd.
Syntax
'Declaration
 
Public Overloads Function CreateGdPictureImageFromHwnd( _
   ByVal HANDLE As IntPtr _
) As Integer
public int CreateGdPictureImageFromHwnd( 
   IntPtr HANDLE
)
public function CreateGdPictureImageFromHwnd( 
    HANDLE: IntPtr
): Integer; 
public function CreateGdPictureImageFromHwnd( 
   HANDLE : IntPtr
) : int;
public: int CreateGdPictureImageFromHwnd( 
   IntPtr HANDLE
) 
public:
int CreateGdPictureImageFromHwnd( 
   IntPtr HANDLE
) 

Parameters

HANDLE
A Window Handle, as IntPtr value. This must be a top-level window or a child of a top level window.

Return Value

0: The image could not be created. Use the GetStat() method to determine the reason this method failed. Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Remarks
You can get the Windows Desktop hwnd with the GetDesktopHwnd method.

This method requires the Image Documents component to run.

Example
Creating a GdPicture image from a Window handle and saving to a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromHwnd(Process.GetCurrentProcess().MainWindowHandle);
    gdpictureImaging.SaveAsPNG(imageID, "image.png");
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also