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 CPOL
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)

Share

About the Author

DCUtility
DCUtility
Canada Canada

Comments and Discussions

 
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 
Hi , I have a good way for you to get a hold of the screen.... :
this method has worked for me without fail , for more than a year now ,
and Im still waiting to find a pc that won't be able to perform this function Smile | :)

To use it simply add the forward declaration (prototype) at the top of your file :
int SnapShot(char* fname);

And then , when you want to use it , simply call it with a file name :

{
//.......some code
SnapShot("img0.bmp");
//.......some code
}

int SnapShot(char* fname)
{
HBITMAP hdib;
BITMAPINFO bi;
BITMAPFILEHEADER bfh;
void *bits; // the dib information...
bits=NULL;
 
int WIDTH,HEIGHT,BPP;
WIDTH = GetSystemMetrics(SM_CXSCREEN);
HEIGHT=GetSystemMetrics(SM_CYSCREEN);
BPP = 24;
//you can use GetSystemMetrics(SM_BITSPERPEL);
// for this call , but i like to use one
//uniform standard for all my dibs :)
 
bi.bmiHeader.biSize = 40;
bi.bmiHeader.biWidth = WIDTH;
bi.bmiHeader.biHeight = HEIGHT;
bi.bmiHeader.biPlanes = 1;
bi.bmiHeader.biBitCount = BPP;
bi.bmiHeader.biCompression = BI_RGB;
bi.bmiHeader.biSizeImage = (BPP/8)*(WIDTH)*(HEIGHT);
bi.bmiHeader.biXPelsPerMeter =0;
bi.bmiHeader.biYPelsPerMeter =0;
bi.bmiHeader.biClrUsed =0;
bi.bmiHeader.biClrImportant =0;
 
bfh.bfType = 0x4D42;
bfh.bfOffBits = sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
bfh.bfSize = bi.bmiHeader.biSizeImage+bfh.bfOffBits;
bfh.bfReserved1 = 0;
bfh.bfReserved2 = 0;
 
HDC hdc = GetDCEx (hWnd,NULL, DCX_CACHE|DCX_LOCKWINDOWUPDATE) ;
HDC fdc = CreateCompatibleDC(hdc);
 
hdib = CreateDIBSection(fdc,&bi,DIB_RGB_COLORS,&bits,NULL,0);
SelectObject(fdc,hdib);
BitBlt(fdc,0,0,WIDTH,HEIGHT,hImgDC,0,0,SRCCOPY);
ReleaseDC(hWnd,hdc);
 

 
//this creates a directory called "snapshots"
//and tells the user what's happening
 
char firstpath[255];
GetCurrentDirectory(255,firstpath);
if(SetCurrentDirectory("SnapShots") == 0)
CreateDirectory("SnapShots",NULL);
SetCurrentDirectory(firstpath);
 
char *tempbuffer=malloc(sizeof(char)*255);
sprintf(tempbuffer,"%s\\SnapShots\\%s",firstpath,fname);
 
MessageBox(NULL,tempbuffer,"Creating...",MB_OK);
 
BOOL bSuccess = FALSE ;
DWORD dwBytesWritten ;
HANDLE hFile ;
hFile = CreateFile (tempbuffer, GENERIC_WRITE,FILE_SHARE_WRITE, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL) ;
if (hFile == INVALID_HANDLE_VALUE)
return FALSE ;
bSuccess = WriteFile (hFile,&bfh,sizeof(bfh), &dwBytesWritten, NULL) ;
 
bSuccess = WriteFile (hFile,&bi.bmiHeader,sizeof(bi.bmiHeader), &dwBytesWritten, NULL) ;
 
bSuccess = WriteFile (hFile,bits,bi.bmiHeader.biSizeImage, &dwBytesWritten, NULL) ;
 
CloseHandle (hFile) ;
DeleteDC(fdc);
DeleteObject(hdib);
free(tempbuffer);
return TRUE;
}


 
The tears shed in vain
and the hatred and pain
will be nothing but dust
at the end of the day

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
Web01 | 2.8.141029.1 | Last Updated 5 Dec 2002
Article Copyright 2002 by DCUtility
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid