|
Well , thanks , but I'm coding in pure C using the
win32 api.
I have something that looks like this :
<br />
HBITMAP hbm;<br />
HDC screendc;<br />
HDC imagedc;<br />
int w;<br />
int h;<br />
<br />
int init(void)<br />
{<br />
screendc = GetDC(NULL);<br />
imagedc = CreateCompatibleDC(screendc);<br />
w = GetSystemMetrics(SM_CXSCREEN);<br />
h = GetSystemMetrics(SM_CYSCREEN);<br />
<br />
hbm = CreateCompatibleBitmap(imagedc,w,h);<br />
ReleaseDC(NULL,screendc);<br />
}<br />
<br />
void CaptureSave(LPSTR szFname)<br />
{<br />
SelectObject(imagedc,hbm);<br />
screendc = GetDC(NULL);<br />
BitBlt(imagedc,0,0,w,h,screendc,0,0,SRCCOPY);<br />
ReleaseDC(NULL,screendc);<br />
<br />
ConvertSaveDIB(szFname,hbm);<br />
}<br />
<br />
void ConvertSaveDIB(LPSTR fn,HBITMAP bm)<br />
{<br />
<br />
<br />
}<br />
The tears shed in vain
and the hatred and pain
will be nothing but dust
at the end of the day
|
|
|
|
|
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
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 :
<br />
{<br />
SnapShot("img0.bmp");<br />
}<br />
<br />
int SnapShot(char* fname)<br />
{<br />
HBITMAP hdib;<br />
BITMAPINFO bi;<br />
BITMAPFILEHEADER bfh;<br />
void *bits;
bits=NULL;<br />
<br />
int WIDTH,HEIGHT,BPP;<br />
WIDTH = GetSystemMetrics(SM_CXSCREEN);<br />
HEIGHT=GetSystemMetrics(SM_CYSCREEN);<br />
BPP = 24; <br />
<br />
bi.bmiHeader.biSize = 40;<br />
bi.bmiHeader.biWidth = WIDTH;<br />
bi.bmiHeader.biHeight = HEIGHT;<br />
bi.bmiHeader.biPlanes = 1;<br />
bi.bmiHeader.biBitCount = BPP;<br />
bi.bmiHeader.biCompression = BI_RGB;<br />
bi.bmiHeader.biSizeImage = (BPP/8)*(WIDTH)*(HEIGHT);<br />
bi.bmiHeader.biXPelsPerMeter =0;<br />
bi.bmiHeader.biYPelsPerMeter =0;<br />
bi.bmiHeader.biClrUsed =0;<br />
bi.bmiHeader.biClrImportant =0;<br />
<br />
bfh.bfType = 0x4D42;<br />
bfh.bfOffBits = sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);<br />
bfh.bfSize = bi.bmiHeader.biSizeImage+bfh.bfOffBits;<br />
bfh.bfReserved1 = 0;<br />
bfh.bfReserved2 = 0;<br />
<br />
HDC hdc = GetDCEx (hWnd,NULL, DCX_CACHE|DCX_LOCKWINDOWUPDATE) ;<br />
HDC fdc = CreateCompatibleDC(hdc);<br />
<br />
hdib = CreateDIBSection(fdc,&bi,DIB_RGB_COLORS,&bits,NULL,0);<br />
SelectObject(fdc,hdib);<br />
BitBlt(fdc,0,0,WIDTH,HEIGHT,hImgDC,0,0,SRCCOPY);<br />
ReleaseDC(hWnd,hdc); <br />
<br />
<br />
<br />
<br />
char firstpath[255];<br />
GetCurrentDirectory(255,firstpath);<br />
if(SetCurrentDirectory("SnapShots") == 0)<br />
CreateDirectory("SnapShots",NULL); <br />
SetCurrentDirectory(firstpath);<br />
<br />
char *tempbuffer=malloc(sizeof(char)*255);<br />
sprintf(tempbuffer,"%s\\SnapShots\\%s",firstpath,fname);<br />
<br />
MessageBox(NULL,tempbuffer,"Creating...",MB_OK);<br />
<br />
BOOL bSuccess = FALSE ;<br />
DWORD dwBytesWritten ;<br />
HANDLE hFile ;<br />
hFile = CreateFile (tempbuffer, GENERIC_WRITE,FILE_SHARE_WRITE, NULL,<br />
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL) ; <br />
if (hFile == INVALID_HANDLE_VALUE)<br />
return FALSE ;<br />
bSuccess = WriteFile (hFile,&bfh,sizeof(bfh), &dwBytesWritten, NULL) ;<br />
<br />
bSuccess = WriteFile (hFile,&bi.bmiHeader,sizeof(bi.bmiHeader), &dwBytesWritten, NULL) ;<br />
<br />
bSuccess = WriteFile (hFile,bits,bi.bmiHeader.biSizeImage, &dwBytesWritten, NULL) ;<br />
<br />
CloseHandle (hFile) ;<br />
DeleteDC(fdc);<br />
DeleteObject(hdib);<br />
free(tempbuffer);<br />
return TRUE;<br />
}<br />
The tears shed in vain
and the hatred and pain
will be nothing but dust
at the end of the day
|
|
|
|
|
Hey,
i only want to say that this works fine!
|
|
|
|
|
Hi,
How can we implement autoscroll feature on it?
I hate to use hypersnap..
|
|
|
|
|
Did Your project based on/inspired by this MSDN sample?
|
|
|
|
|
Very nice control, love the interface.
i was wondering if there's a way to caputre the coordinates of the selected region using your DLL?
I need to find out the x1, y1, x2, y2 coordinates of user selected area on the screen.
Also do you have an API to output the captured image to certain format?
Thanks a lot!!
Dave
|
|
|
|
|
Actually you cannot get the coordinates of selected region and no other image formats included.
For the coordinates, I will add CRect function to get the x1, y1, x2, y2 coordinates of user selected area on the screen ex: HBITMAP GetRegionImage(LPRECT lprc);
For captured image format, nothing new! Your app need to convert HBITMAP Handle to other image format.
===== Last week, one people offer me 1500$ US to have the source code and at this moment, I dont know if I will accept this offer. =====
->L'enfer est pavé de bonnes intentions! :-S
->The road to hell is paved with good intentions! :-S
|
|
|
|
|
Cool, thanks.
the CRect function is not currently available right?
any estimates on when?
|
|
|
|
|
This is a joke. If you dont want to share the .dll source you should post your program under some other topic such as "PictureBox with Scrollbars". This site is for sharing source code. What exactly was you looking in here? Admiration? Bleh...
|
|
|
|
|
Have you stolen the library from some other proejct. Can you post the link or refrance
In my openion the name of the project should be "Using a dll in VC and VB without my help"
Hardwork is key to success...
Bilal Ahmed
|
|
|
|
|
This library is my own A-Z work. Its free and have only 4 functions to call. Look in the demo to see how call theses functions. Very easy!!!
->L'enfer est pavé de bonnes intentions! :-S
->The road to hell is paved with good intentions! :-S
|
|
|
|
|
This tool is very slick & powerfull. I like it!
I did find one bug. I have a dual monitor setup here, and it only allows me to capture stuff from the primary monitor. Thanks.
|
|
|
|
|
I like it! Thanks!
==============================================
SkinMagic SDK Library for C/C++
The better solution for write skinnable application
http://www.appspeed.com
==============================================
|
|
|
|
|
Thank to you jedyking
->L'enfer est pavé de bonnes intentions! :-S
->The road to hell is paved with good intentions! :-S
|
|
|
|
|
please but the full source code or get away from the developers
Thanks and Best Regards,
Ahmed Ismaiel
sonork ID 100.11442
|
|
|
|
|
Yeahh, put the full source code!!!!!!
|
|
|
|
|
Actually, there is no *requirement* that he post his source code. However, since he didn't post his source code, his article is made that much less pertinent or useful.
All things considered, this article sucks.
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
Why the source code for SnaperHelper.dll is not included?
|
|
|
|
|
Hello,
I couldn't help noticing that the icon provided in the screen-shot is very similar to the one Hyper-Snap[^] is using. Do you work for Hyper Ionics and are making public a dll without providing the source code? Just curios.
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
Why does the DLL link to WINMM.DLL and binds to PlaySoundA ?? Is that really necessary for a screenshot lib?
I don't think this is a serious possesion, and the evil most likely comes from your hand. Colin J Davies, The Lounge
|
|
|
|
|
Salut,
Il manque des fichiers!
Max.
|
|
|
|
|
Salut Max, si tu veux parler des fichiers sources de la librarie et bien tu as raison car plus haut dans cet article, il est spécifier que ce source n'est pas distribué.
En passant, j'ai placé cet article dans Free Tools justement pour ne pas me faire demander le source de ma libraire!!! Ça fait jamais l'affaire de tout le monde mais bon...
Salutation à tous les Montréalais!
The road to hell is paved with good intentions!
|
|
|
|
|
1. Source code is partial
2. Very poor documentation
Kant
Sonork-100.28114
If nothing works. Try Pointers.
|
|
|
|
|
Hahahahaha!
1- Hey men, if you are unable to implement this code easily in other application it's because your are not true programmer!!!!
2- For the documentation, look in the demo and it will take you about 5 minutes to understand the implementation if you have a brain.
Any way fy!!
The road to hell is paved with good intentions!
|
|
|
|
|
You should watch your language a bit.
Dany Cantin wrote:
if you are unable to implement this code easily in other application it's because your are not true programmer!!!!
Wrong. Its because he may not understand what seems obvious to you. Thats why CP is an article site and not a download site (like cnet and others): its about the article explaining the code.
Dany Cantin wrote:
Any way fy!!
Tell that your mother but not here on CP.
I don't think this is a serious possesion, and the evil most likely comes from your hand. Colin J Davies, The Lounge
|
|
|
|
|