Click here to Skip to main content
Licence CPOL
First Posted 4 Dec 2002
Views 214,962
Bookmarked 58 times

Fast screen, window, region and print screen capture

By | 4 Dec 2002 | Article
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

Other
DCUtility
Canada Canada

Member

Home Page

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralFixing the region PinsussWon Huh21:15 24 Oct '04  
GeneralScreen capture fails for multiple instances Pinmembervishalmore23:33 4 Oct '04  
GeneralScreen capture Pinmemberangello4:06 16 Jun '04  
GeneralRe: Screen capture PinsussAnonymous0:09 1 Aug '04  
GeneralRe: Screen capture Pinmembereligetiv11:21 9 Jan '05  
GeneralRe: Screen capture PinmemberMax_Power_Up23:54 25 May '06  
GeneralRe: Screen capture PinmemberMax_Power_Up1:41 27 Nov '06  
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

GeneralVery well Pinmemberbenni1:31 19 Mar '04  
Generalautoscroll feature Pinmemberledang22:29 5 Jan '04  
Generalsource code PinmemberVK23:28 14 Dec '03  
Generalregion coordinates Pinmemberhsiaod22:39 11 Jun '03  
GeneralRe: region coordinates PinmemberDany Cantin2:22 12 Jun '03  
GeneralRe: region coordinates Pinmemberhsiaod9:57 12 Jun '03  
GeneralRe: region coordinates Pinmemberobni1997:00 13 Dec '06  
GeneralWhats it all about if source code is not provided... PinmemberBilal Ahmed16:21 9 Jun '03  
GeneralRe: Whats it all about if source code is not provided... PinmemberDany Cantin16:52 9 Jun '03  
GeneralNice work Pinmembermgama8:20 19 Feb '03  
GeneralGood job!!! Pinmemberjedyking6:53 22 Jan '03  
GeneralRe: Good job!!! PinmemberDany Cantin11:22 23 Jan '03  
Generalvery poor PinmemberAhmed Ismaiel Zakaria8:37 6 Dec '02  
GeneralRe: very poor PinmemberCosmoS2k9:21 6 Dec '02  
GeneralRe: very poor PinmemberJohn Simmons / outlaw programmer14:39 6 Dec '02  
QuestionWhy ??? Pinmemberhugo20107:04 6 Dec '02  
GeneralIcon similar to Hyper-Snap PinmemberAlexandru Savescu4:34 6 Dec '02  
QuestionPlaySoundA ??? PinmemberAndreas Saurwein3:51 6 Dec '02  

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.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120529.1 | Last Updated 5 Dec 2002
Article Copyright 2002 by DCUtility
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid