
kidpigeyre
|
Jte met ma fonction :
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; RECT rect; static HPEN h_stylo; static POINT lppoint; static POINT lppointo; static POINT lppointt; POINT lppointa; static Cellule *point; Cellule *temppoint; static int boucle; float coef; int vn; static int couleurr; static int couleurv; static int couleurb; static COLORREF color; static int largeur; static int hauteur; int i,k; static int gboucle; ///////////// définition static handle hthread;
switch(iMsg) {
case WM_CREATE:
point = NULL; h_stylo=CreatePen(PS_SOLID, 1, RGB(220,0,0)); boucle=0; gboucle=0;
case WM_SIZE : largeur=LOWORD(lParam); hauteur=HIWORD(lParam); return 0;
case WM_TIMER : switch(wParam) { case IDM_TIMERL : if (boucle > (nbparticule-1)) { for(k=0;k<nbgerbe;k++) { for(i=0;i<(grosseurpoint*grosseurpoint);i++) suppression_tete(&point); } } if(boucle<longueurgerbe) { insertaff_fin(&point,color); boucle++; } else { KillTimer(hwnd, IDM_TIMERL); SetTimer(hwnd, IDM_TIMERD, degrad, (TIMERPROC) NULL); } break;
case IDM_TIMERD : if(degrade(&point,color)==nbparticule*nbgerbe*grosseurpoint*grosseurpoint) { boucle=0; suppression_tout(&point); KillTimer(hwnd, IDM_TIMERD); if(gboucle==1) { srand(time(NULL)); largcercle=(rand() % 8)+4; (lppointo.x)=(rand() % (largeur-20))+10; (lppointo.y)=(rand() % (hauteur/2))+10; (lppointt.x)=largeur/2; (lppointt.y)=hauteur; (lppoint.x)=(lppointt.x); (lppoint.y)=(lppointt.y); couleurr=(rand() % 200) + 50; couleurv=(rand() % 200) + 50; couleurb=(rand() % 200) + 50; color=RGB(couleurr,couleurv,couleurb); SetTimer(hwnd, IDM_TIMERR, lancement, (TIMERPROC) NULL); } } break;
case IDM_TIMERR : if((lppointt.y)>(lppointo.y)) { insert_fin(&point,(lppointt.x),(lppointt.y),RGB(255,255,255)); if((lppointo.x)<(lppoint.x)) { coef=((lppointo.y)-(lppoint.y))*1.0/((lppointo.x)-(lppoint.x)); if(grosseurpoint*1.0/coef>grosseurpoint)(lppointt.x)-=grosseurpoint/coef; else (lppointt.x)-=grosseurpoint; } else if((lppointo.x)>(lppoint.x)) { coef=((lppointo.y)-(lppoint.y))*1.0/((lppointo.x)-(lppoint.x)); if(grosseurpoint*1.0/coef>grosseurpoint)(lppointt.x)+=grosseurpoint/coef; else (lppointt.x)+=grosseurpoint; } vn=(lppointo.y)-coef*(lppointo.x); (lppointt.y)=coef*(lppointt.x)+vn; if (boucle>nbparticulefusee) { for(i=0;i<(grosseurpoint*grosseurpoint);i++) suppression_tete(&point); } boucle++; } else { suppression_tout(&point); boucle=0; (lppoint.x)=(lppointo.x); (lppoint.y)=(lppointo.y); creer_cercle(&point,(lppointo.x),(lppointo.y),largcercle,color);////////////////////jvoudrai insérer le hthread=createthread(null,0,wndproc,null,0,null); sndPlaySound("feu.wav", SND_SYNC); SetTimer(hwnd, IDM_TIMERL, affichage, (TIMERPROC) NULL); KillTimer(hwnd, IDM_TIMERR); } break; } GetClientRect (hwnd, &rect); InvalidateRect (hwnd, &rect, TRUE); return 0;
case WM_COMMAND : switch(wParam) { case IDM_LANCER : srand(time(NULL)); suppression_tout(&point); largcercle=(rand() % 8)+4; (lppointo.x)=(rand() % (largeur-20))+10; (lppointo.y)=(rand() % (hauteur/2))+10; (lppointt.x)=largeur/2; (lppointt.y)=hauteur; (lppoint.x)=(lppointt.x); (lppoint.y)=(lppointt.y); couleurr=(rand() % 200) + 50; couleurv=(rand() % 200) + 50; couleurb=(rand() % 200) + 50; color=RGB(couleurr,couleurv,couleurb); SetTimer(hwnd, IDM_TIMERR, lancement, (TIMERPROC) NULL); return 0;
case IDM_BOUCLE : srand(time(NULL)); suppression_tout(&point); largcercle=(rand() % 8)+4; (lppointo.x)=(rand() % (largeur-20))+10; (lppointo.y)=(rand() % (hauteur/2))+10; (lppointt.x)=largeur/2; (lppointt.y)=hauteur; (lppoint.x)=(lppointt.x); (lppoint.y)=(lppointt.y); couleurr=(rand() % 200) + 50; couleurv=(rand() % 200) + 50; couleurb=(rand() % 200) + 50; color=RGB(couleurr,couleurv,couleurb); gboucle=1; SetTimer(hwnd, IDM_TIMERR, lancement, (TIMERPROC) NULL); return 0;
case IDM_ARRET : gboucle=0; return 0; case IDM_QUIT : if((MessageBox( hwnd, "Voulez-vous vraiment quitter?", "Fermeture", MB_OKCANCEL ))==IDOK) PostQuitMessage (0); return 0; } return 0;
case WM_PAINT : hdc =BeginPaint (hwnd, &ps); GetClientRect (hwnd, &rect); SelectObject (hdc, h_stylo); temppoint=point; while(point!=NULL) { (lppointa.x)=(point->x); (lppointa.y)=(point->y); ClientToScreen(hwnd,&lppointa); SetPixel(hdc,(lppointa.x),(lppointa.y), RGB((point->rouge),(point->vert),(point->bleu))); point=(point->suiv); } point=temppoint; EndPaint (hwnd, &ps); return 0;
case WM_CLOSE : if((MessageBox( hwnd, "Voulez-vous vraiment quitter?", "Fermeture", MB_OKCANCEL ))==IDOK) PostQuitMessage (0); return 0; case WM_DESTROY : suppression_tout(&point);//////////////et la le closehandle(hthread); KillTimer(hwnd, IDM_TIMERL); KillTimer(hwnd, IDM_TIMERR); KillTimer(hwnd, IDM_TIMERD); DeleteObject (h_stylo); PostQuitMessage (0);
return 0; } return DefWindowProc( hwnd, iMsg, wParam, lParam); }
|