Cherche explication d'un code

Résolu
jopiou Messages postés 10 Date d'inscription vendredi 17 novembre 2000 Statut Membre Dernière intervention 6 mai 2006 - 7 janv. 2006 à 19:59
cs_Joky Messages postés 1787 Date d'inscription lundi 22 novembre 2004 Statut Membre Dernière intervention 31 janvier 2009 - 7 janv. 2006 à 20:51
Bonsoir voila je cherche quelqu'un pouvant m'expliquer ce code



HBITMAP hbmp;

int cxDib, cyDib,idximg;

char *szimages = {"Chat.jpg"};



void __stdcall ImgLoad()

{

HANDLE file; ===> le handle c'est quoi deja ? enfin si on peut m'expliquer rapidement

DWORD bmpsz, val; ===> ledword aussi si on peut m'expliquer

HANDLE hheap;

BYTE *pmem;

BITMAP bmp;

if(hbmp) {DeleteObject(hbmp); hbmp = 0;}

file = CreateFile(szimages, GENERIC_READ, 0, 0, OPEN_EXISTING,


FILE_FLAG_SEQUENTIAL_SCAN, 0);

if(file == INVALID_HANDLE_VALUE) return;

bmpsz = GetFileSize(file, 0);

hheap GetProcessHeap(); > qu'est-ce que cette fonction?

pmem (BYTE*) HeapAlloc(hheap, 0, bmpsz);> pareil pour heapalloc

if(pmem) ReadFile(file, pmem, bmpsz, &val, 0);

CloseHandle(file);

if(!pmem) return;

hbmp = bnBmpFromMemory(pmem, bmpsz);

HeapFree(hheap, 0, pmem);

if(hbmp) {

if(GetObject(hbmp, sizeof(bmp), &bmp)) {

cxDib bmp.bmWidth; cyDib bmp.bmHeight;

}

}

}



void __stdcall onPaint(HWND hdlg)

{

PAINTSTRUCT ps;

HDC hdc, memdc;

RECT rct;

hdc = BeginPaint(hdlg, &ps);

if(hbmp) {

GetClientRect(hdlg, &rct);

memdc = CreateCompatibleDC(hdc);

SelectObject(memdc, hbmp);

StretchBlt(hdc, 0, 0, (rct.right-150), rct.bottom, memdc, 0, 0, cxDib, cyDib, SRCCOPY);

DeleteDC(memdc);

}

EndPaint(hdlg, &ps);

}



BOOL CALLBACK AppDlgProc(HWND hdlg, UINT mssg, WPARAM wParam, LPARAM lParam)

{

switch(mssg) {

case WM_PAINT:

onPaint(hdlg);

break;

case WM_TIMER:

if(++idximg > 2) idximg = 0;

ImgLoad();

InvalidateRect(hdlg, 0, 0);

break;

case WM_INITDIALOG:

SetClassLong(hdlg, GCL_HICON, (long)LoadIcon(0, IDI_APPLICATION));

idximg = 0;

ImgLoad();

SetTimer(hdlg, 1, 1500, 0);

return 1;

case WM_COMMAND:

if(wParam == IDCANCEL) {KillTimer(hdlg, 1); EndDialog(hdlg, 0);}

}

return 0;

}



int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, int)

{

DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_APP), 0, AppDlgProc, 0);

return 0;

}



Merci beaucoup si vous pouvez m'aider

3 réponses

cs_Joky Messages postés 1787 Date d'inscription lundi 22 novembre 2004 Statut Membre Dernière intervention 31 janvier 2009 2
7 janv. 2006 à 20:08
Un HANDLE c'est comme n'importe qu'elle variable, elle permet d'identifier un Objet

Un DWORD c'est une variable codée sur 8*4 = 32 Bits donc en binaire de la forme

00000000000000000000000000000000


BYTE *pmem; un tableau de BYTE (attention terme très ambigu lol)

Pour ce qui est des Heap c'est un méthodes d'allocation de mémoire, pour plus de détails faut lire Richter



Et après j'vois pas ce qui te pose problème :o
if(!Meilleur("Joky")) return ERREUR;<
3
cs_Joky Messages postés 1787 Date d'inscription lundi 22 novembre 2004 Statut Membre Dernière intervention 31 janvier 2009 2
7 janv. 2006 à 20:51
3
jopiou Messages postés 10 Date d'inscription vendredi 17 novembre 2000 Statut Membre Dernière intervention 6 mai 2006
7 janv. 2006 à 20:29
J'aimerais bien savoir en plsu a quoi sert



StretchBlt(hdc, 0, 0, (rct.right-150), rct.bottom, memdc, 0, 0, cxDib, cyDib, SRCCOPY);



merci
0
Rejoignez-nous