Cherche source!!

Résolu
Chap71 Messages postés 19 Date d'inscription mercredi 1 juin 2005 Statut Membre Dernière intervention 24 juin 2005 - 23 juin 2005 à 08:58
cs_magma Messages postés 198 Date d'inscription vendredi 4 avril 2003 Statut Membre Dernière intervention 18 mars 2011 - 25 juin 2005 à 11:38
Salut!!!
Je cherche une source c++ (ou c) qui premetrai que lorsque l'on appui sur Imp écr Syst ,nous colle directement l'image avec le nom et le chemin kon lui donne. Cela m'arrangerai beaucoup.
Merci d'avance

Belle de loin mais loin dêtre belle même si la beauté est dans l'oeil de celu qui regarde...

10 réponses

Zootella Messages postés 252 Date d'inscription vendredi 10 juin 2005 Statut Membre Dernière intervention 5 septembre 2006
23 juin 2005 à 12:24
Tu n'as pas besoin de passer par Paint



HWND pWnd = GetDesktopWindow();

HBITMAP bitmap;

HDC memDC;

HDC dc = GetWindowDC(pWnd);



memDC=CreateCompatibleDC(dc);



int ScreenWidth = GetDeviceCaps(dc, HORZRES);

int ScreenHeight = GetDeviceCaps(dc, VERTRES);



bitmap=CreateCompatibleBitmap(dc, ScreenWidth, ScreenHeight);



SelectObject(memDC,bitmap);

BitBlt(memDC, 0, 0, ScreenWidth,ScreenHeight, dc, 0, 0, SRCCOPY);



ce code met le screenshot dans memDC, il faut juste le sauvegarder dans un fichier :



int __stdcall HdcToBmpFile(HDC hdc, char *pszflname)



{

HDC memdc;

HANDLE hfl;

DWORD dwBytes, dwWidth, dwHeight, dwNumColors, dwBPP, ColorSize;

void *pBits;

HBITMAP hbmp;

BITMAPFILEHEADER fileheader;

BITMAPINFOHEADER infoheader;

RGBQUAD colors[256];

BITMAPINFO bmpinfo;

HGDIOBJ hret;

dwWidth = GetDeviceCaps(hdc, HORZRES);

dwHeight = GetDeviceCaps(hdc, VERTRES);

dwBPP = GetDeviceCaps(hdc, BITSPIXEL);

if(dwBPP <8) dwNumColors 256;

else dwNumColors = 0;

if(!(memdc = CreateCompatibleDC(hdc))) return 0;

bmpinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);

bmpinfo.bmiHeader.biWidth = dwWidth;

bmpinfo.bmiHeader.biHeight = dwHeight;

bmpinfo.bmiHeader.biPlanes = 1;

bmpinfo.bmiHeader.biBitCount = (WORD) dwBPP;

bmpinfo.bmiHeader.biCompression = BI_RGB;

bmpinfo.bmiHeader.biSizeImage = 0;

bmpinfo.bmiHeader.biXPelsPerMeter = 0;

bmpinfo.bmiHeader.biYPelsPerMeter = 0;

bmpinfo.bmiHeader.biClrUsed = dwNumColors;

bmpinfo.bmiHeader.biClrImportant = dwNumColors;

hbmp = CreateDIBSection(hdc, &bmpinfo, DIB_PAL_COLORS, &pBits, NULL, 0);

if(!hbmp) goto errato;

hret = SelectObject(memdc, hbmp);

if(!hret || (hret == HGDI_ERROR)) goto errato;

if(!BitBlt(memdc, 0, 0, dwWidth, dwHeight, hdc, 0, 0, SRCCOPY)) goto errato;

if(dwNumColors) dwNumColors = GetDIBColorTable(memdc, 0, dwNumColors, colors);

fileheader.bfType = 0x4D42;

ColorSize = dwNumColors * sizeof(RGBQUAD);

fileheader.bfSize = ((dwWidth*dwHeight*dwBPP)
>> 3)+ColorSize+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);

fileheader.bfReserved1 fileheader.bfReserved2 0;

fileheader.bfOffBits = ColorSize+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);

infoheader.biSize = sizeof(BITMAPINFOHEADER);

infoheader.biWidth = dwWidth;

infoheader.biHeight = dwHeight;

infoheader.biPlanes = 1;

infoheader.biBitCount = (WORD) dwBPP;

infoheader.biCompression = BI_RGB;

infoheader.biSizeImage infoheader.biClrImportant 0;

infoheader.biXPelsPerMeter infoheader.biYPelsPerMeter 0;

infoheader.biClrUsed = dwNumColors;

hfl = CreateFile(pszflname,GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);

if(hfl == INVALID_HANDLE_VALUE) {DeleteObject(hbmp); goto errato;}

WriteFile(hfl, &fileheader, sizeof(BITMAPFILEHEADER), &dwBytes, 0);

WriteFile(hfl, &infoheader, sizeof(BITMAPINFOHEADER), &dwBytes, 0);

if(!dwNumColors) WriteFile(hfl, colors, ColorSize, &dwBytes, 0);

ColorSize = (dwWidth*dwHeight*dwBPP) >> 3;

WriteFile(hfl, pBits, ColorSize, &dwBytes, 0);

CloseHandle(hfl);

DeleteObject(hbmp);

DeleteDC(memdc);

return 1;

errato:

DeleteDC(memdc); return 0;

}



Je sais pas si il y'a plus court comme fonction...
3
cs_magma Messages postés 198 Date d'inscription vendredi 4 avril 2003 Statut Membre Dernière intervention 18 mars 2011
25 juin 2005 à 11:38
//-----------------------------------------------------------------------------
// Clip2Bmp.c
//-----------------------------------------------------------------------------
#include <windows.h>


#define TIMERFREQ 100
#define FILENAME "c:\\clip2bmp.bmp"


//-----------------------------------------------------------------------------
BOOL clip2bmp(LPCTSTR pszFileBMP)
{
HDC hdcMem;
HDC hdcScr;
HBITMAP hBitmap;
HBITMAP hBitOld;
BITMAP bm;
BITMAPINFO bmi;
BITMAPFILEHEADER bfh;
BITMAPINFOHEADER bmih;
HANDLE hFile;
LPBYTE pPixels;
DWORD dwBytes;
DWORD dwTmp;


if(OpenClipboard(NULL))
{
hBitmap = GetClipboardData(CF_BITMAP);
CloseClipboard();
}
else
return FALSE;


if(!hBitmap)
return FALSE;


if(!GetObject(hBitmap, sizeof(bm), &bm))
return FALSE;

hdcScr = GetDC(NULL);
hdcMem = CreateCompatibleDC(hdcScr);
hBitOld = (HBITMAP) SelectObject(hdcMem, hBitmap);


ZeroMemory(&bmih, sizeof(bmih));
bmih.biSize = sizeof(BITMAPINFOHEADER);
bmih.biWidth = bm.bmWidth;
bmih.biHeight = bm.bmHeight;
bmih.biBitCount = bm.bmBitsPixel;
bmih.biCompression = BI_RGB;
bmih.biPlanes = 1;
bmi.bmiHeader = bmih;


dwBytes = bmih.biWidth * bmih.biHeight * (bmih.biBitCount / 8);


if(!(pPixels = (LPBYTE) GlobalAlloc(GMEM_FIXED, dwBytes)))
goto Erreur;

if(!GetDIBits(hdcMem, hBitmap, 0, (UINT) bmih.biHeight, pPixels, &bmi, DIB_RGB_COLORS))
goto Erreur;

bfh.bfType = 0x4d42;
bfh.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
bfh.bfSize = (DWORD) sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + dwBytes; bfh.bfReserved1 bfh.bfReserved2 0;

hFile = CreateFile(pszFileBMP, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);


if(hFile == INVALID_HANDLE_VALUE)
goto Erreur;

if(!WriteFile(hFile, (LPVOID) &bfh, sizeof(BITMAPFILEHEADER), (LPDWORD) &dwTmp, NULL))
goto Erreur;

if(!WriteFile(hFile, (LPVOID) &bmih, sizeof(BITMAPINFOHEADER), (LPDWORD) &dwTmp, NULL))
goto Erreur;

if(!WriteFile(hFile, (LPVOID) pPixels, dwBytes, (LPDWORD) &dwTmp, NULL))
goto Erreur;


GlobalFree(pPixels);
CloseHandle(hFile);
SelectObject(hdcMem, hBitOld);
ReleaseDC(NULL, hdcScr);
DeleteDC(hdcMem);
return TRUE;

Erreur:
if(pPixels)
GlobalFree(pPixels);
if(hFile)
{
CloseHandle(hFile);
DeleteFile(pszFileBMP);
}
SelectObject(hdcMem, hBitOld);
ReleaseDC(NULL, hdcScr);
DeleteDC(hdcMem);
return FALSE;
}


//-----------------------------------------------------------------------------
void CALLBACK TimerProc(HWND hWnd, UINT uMsg, UINT uTimerId, DWORD dwTime)
{
if(HIBYTE(GetAsyncKeyState(VK_SNAPSHOT)))
clip2bmp(FILENAME);
}


//-----------------------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int iCmdShow)
{
MSG msg;

SetTimer(NULL, 1, TIMERFREQ, TimerProc);

while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}


KillTimer(NULL, 1);
return msg.wParam;
}
3
Zootella Messages postés 252 Date d'inscription vendredi 10 juin 2005 Statut Membre Dernière intervention 5 septembre 2006
23 juin 2005 à 10:25
Tu veux dire faire un screenshot maker ? ou un hook sur la cette touche ?
0
cs_LordBob Messages postés 2865 Date d'inscription samedi 2 novembre 2002 Statut Membre Dernière intervention 11 mai 2009 9
23 juin 2005 à 11:38
screenshot maker, il veut en fait que quand il fait l'imprime écran, bah le logiciel se lance avec la capture qui a été faite !
Bob...

"La chance accorde ses faveur aux esprits avertis..."
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Chap71 Messages postés 19 Date d'inscription mercredi 1 juin 2005 Statut Membre Dernière intervention 24 juin 2005
23 juin 2005 à 12:00
Je veux que lorsue que je fai une impression d'écran, ma capture soit collées dans paint, que paint se ferme, et qu'il enregistre l'image la ou on lui dit..

Belle de loin mais loin dêtre belle même si la beauté est dans l'oeil de celu qui regarde...
0
Chap71 Messages postés 19 Date d'inscription mercredi 1 juin 2005 Statut Membre Dernière intervention 24 juin 2005
23 juin 2005 à 14:17
Merci bcp!!!
Juste pour info: tu travail sous c++ builder ou pas?
Moi c la 5.

Belle de loin mais loin dêtre belle même si la beauté est dans l'oeil de celu qui regarde...
0
Chap71 Messages postés 19 Date d'inscription mercredi 1 juin 2005 Statut Membre Dernière intervention 24 juin 2005
23 juin 2005 à 14:32
Ya u pti hic!!
Jvoi pa de main et je ne sais pas dans quoi le mettre et sous quelle forme organiser la source.

Peux tu m'aider et me dir avec koi tu développe stp je ne suis qu'un novice!!
Merci a toi pour ta patience!!

Belle de loin mais loin dêtre belle même si la beauté est dans l'oeil de celu qui regarde...
0
cs_LordBob Messages postés 2865 Date d'inscription samedi 2 novembre 2002 Statut Membre Dernière intervention 11 mai 2009 9
23 juin 2005 à 20:32
normal que tu ne vois pas de main(), Zootella ta écris une fonction qui fait juste ce que tu demandes et non un programme complet.
tu dois ecrire toi meme le programme et appelé la fonction et elle enregistrera la capture !
Bob...

"La chance accorde ses faveur aux esprits avertis..."
0
Zootella Messages postés 252 Date d'inscription vendredi 10 juin 2005 Statut Membre Dernière intervention 5 septembre 2006
23 juin 2005 à 22:26
bah oui comme l'a dit [auteurdetail.aspx?ID=17350 LordBob]



Moi j'utilise visual c++ 6.



j'ai jamais utilisé borland donc je sais pas si ça compilera sans modification à faire.
0
Chap71 Messages postés 19 Date d'inscription mercredi 1 juin 2005 Statut Membre Dernière intervention 24 juin 2005
24 juin 2005 à 08:12
Oki merci a vous deux c'est cool!!
En même temps joré pu y deviner que fallé que je le fasee moi même le main.. lol.
Aller!!! BVone prog et encore merci!!

Belle de loin mais loin dêtre belle même si la beauté est dans l'oeil de celu qui regarde...
0
Rejoignez-nous