Click here to Skip to main content
Click here to Skip to main content

Fast screen, window, region and print screen capture

, 4 Dec 2002
Rate this:
Please Sign up or sign in to vote.
Screen Snaper is an fast screen, window, region and print screen capture

Sample Image - ScreenSnaper.gif

Introduction

Screen Snaper is an simple application for Screen capture and snapshot. The application use exported function from library SnaperHelper.dll compatible with VC, VB, Delphi and other languages that can use DLL.

Snapshot features

  • Get Desktop window
  • Get Window on the Desktop
  • Get Region of the desktop
  • Trap Print Screen key

In Window and Region capture mode, an helper show the zoomed position under the cursor and the current color. These modes also include keys shortcut and pop menu to permit switch between mode and much more...

About demo

This demo application include source code for clients in VC and VB. The source code of library SnaperHelper.dll is not provided.

History

  • 8 december 2002 - Demo project updated. Now include missing SnaperHelper.lib and SnaperHelperLib.h.

Enjoy!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

DCUtility
DCUtility
Canada Canada

Comments and Discussions

 
QuestionHow can I use the dll in C# PinmemberH.Riazi26-Jul-06 11:38 
Generalplese~~ send me the source code of SnaperHelper.dll Pinmemberend_inmyhome27-Jun-06 15:27 
GeneralWill this work in log off mode Pinmemberakarwa22-May-06 7:26 
GeneralPlease Help PinmemberMax_Power_Up11-May-06 1:23 
AnswerRe: Please Help PinmemberTalk To The Hand25-May-06 10:35 
I really don't know why this article is in the CODE project, if there is no CODE...
Use this, it's not perfect, but it's here!

/////////////////////////////////////////////////////////////////////////
//////////////////// THIS CODE WASN'T CREATED BY ME, BUT I DON'T REMEMBER
//////////////////// THE AUTHOR'S NAME. SORRY!
/////////////////////////////////////////////////////////////////////////
 

public Image CaptureScreen()
{
return CaptureWindow( User32.GetDesktopWindow() );
}
///
/// Creates an Image object containing a screen shot of a specific window
///

/// The handle to the window. (In windows forms, this is obtained by the Handle property)
///
public Image CaptureWindow(IntPtr handle)
{
// get te hDC of the target window
IntPtr hdcSrc = User32.GetWindowDC(handle);
// get the size
User32.RECT windowRect = new User32.RECT();
User32.GetWindowRect(handle,ref windowRect);
int width = windowRect.right - windowRect.left;
int height = windowRect.bottom - windowRect.top;
// create a device context we can copy to
IntPtr hdcDest = GDI32.CreateCompatibleDC(hdcSrc);
// create a bitmap we can copy it to,
// using GetDeviceCaps to get the width/height
IntPtr hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc,width,height);
// select the bitmap object
IntPtr hOld = GDI32.SelectObject(hdcDest,hBitmap);
// bitblt over
GDI32.BitBlt(hdcDest,0,0,width,height,hdcSrc,0,0,GDI32.SRCCOPY);
// restore selection
GDI32.SelectObject(hdcDest,hOld);
// clean up
GDI32.DeleteDC(hdcDest);
User32.ReleaseDC(handle,hdcSrc);
// get a .NET image object for it
Image img = Image.FromHbitmap(hBitmap);
// free up the Bitmap object
GDI32.DeleteObject(hBitmap);
return img;
}
///
/// Captures a screen shot of a specific window, and saves it to a file
///

///
///
///
public void CaptureWindowToFile(IntPtr handle, string filename, ImageFormat format)
{
Image img = CaptureWindow(handle);
img.Save(filename,format);
}
///
/// Captures a screen shot of the entire desktop, and saves it to a file
///

///
///
public void CaptureScreenToFile(string filename, ImageFormat format)
{
Image img = CaptureScreen();
img.Save(filename,format);
}
 
///
/// Helper class containing Gdi32 API functions
///

private class GDI32
{

public const int SRCCOPY = 0x00CC0020; // BitBlt dwRop parameter
[DllImport("gdi32.dll")]
public static extern bool BitBlt(IntPtr hObject,int nXDest,int nYDest,
int nWidth,int nHeight,IntPtr hObjectSource,
int nXSrc,int nYSrc,int dwRop);
[DllImport("gdi32.dll")]
public static extern IntPtr CreateCompatibleBitmap(IntPtr hDC,int nWidth,
int nHeight);
[DllImport("gdi32.dll")]
public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
[DllImport("gdi32.dll")]
public static extern bool DeleteDC(IntPtr hDC);
[DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);
[DllImport("gdi32.dll")]
public static extern IntPtr SelectObject(IntPtr hDC,IntPtr hObject);
}
 
///
/// Helper class containing User32 API functions
///

private class User32
{
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[DllImport("user32.dll")]
public static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll")]
public static extern IntPtr GetWindowDC(IntPtr hWnd);
[DllImport("user32.dll")]
public static extern IntPtr ReleaseDC(IntPtr hWnd,IntPtr hDC);
[DllImport("user32.dll")]
public static extern IntPtr GetWindowRect(IntPtr hWnd,ref RECT rect);
}

Generalplese send me the source code of SnaperHelper.dll Pinmemberayyagarishankar20-Feb-06 20:54 
Generalwant source code of SnaperHelper.dll Pinmemberayyagarishankar20-Feb-06 20:49 
Generalcapture image without displaying application window Pinmemberjags_vc15-Feb-05 19:10 
GeneralRe: capture image without displaying application window Pinmembervishalmore26-Feb-05 2:15 
GeneralPrinting a Screen capture in C# PinsussAnonymous26-Jan-05 15:41 
GeneralDemo Update For MSVS .NET 2003 (VB And C#) PinmemberDany Cantin13-Nov-04 16:44 
GeneralFixing the region PinsussWon Huh24-Oct-04 21:15 
GeneralScreen capture fails for multiple instances Pinmembervishalmore4-Oct-04 23:33 
GeneralScreen capture Pinmemberangello16-Jun-04 4:06 
GeneralRe: Screen capture PinsussAnonymous1-Aug-04 0:09 
GeneralRe: Screen capture Pinmembereligetiv9-Jan-05 11:21 
GeneralRe: Screen capture PinmemberMax_Power_Up25-May-06 23:54 
GeneralRe: Screen capture PinmemberMax_Power_Up27-Nov-06 1:41 
GeneralVery well Pinmemberbenni19-Mar-04 1:31 
Generalautoscroll feature Pinmemberledang5-Jan-04 22:29 
Generalsource code PinmemberVK14-Dec-03 23:28 
Generalregion coordinates Pinmemberhsiaod11-Jun-03 22:39 
GeneralRe: region coordinates PinmemberDany Cantin12-Jun-03 2:22 
GeneralRe: region coordinates Pinmemberhsiaod12-Jun-03 9:57 
GeneralRe: region coordinates Pinmemberobni19913-Dec-06 7:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 5 Dec 2002
Article Copyright 2002 by DCUtility
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid