Merci ça fait trop plaisir de le voir marcher, ça va faire une bonne heure que ça tourne sans planter.
Je me suis même payé le luxe de rajouter un double buffering, en prenant compte de ces nouvelles concidérations.
Je pensais pas que l'objet n'était pas détruit si on en créait plusieurs sur le même (hp et non pas hp1,2 ...) et j'avais pas trop
compris comment on rechargeait les objets initiaux dans le DC.
C'était ça l'erreur.
Encore merci.
Je vais mettre le résultat du paint pour que ça puisse servir à d'autre:
case WM_PAINT:
{
HDC hdcsound,hdcsoundtmp;
PAINTSTRUCT pssound;
HPEN hp1, hp2, hp3, hp4;
HPEN holdp;
HBRUSH hb; // Fond du scope
HBRUSH holdb;
HBITMAP hOldBmp;
HBITMAP hMemBmp;
LOGBRUSH lb; // Style de la brush
rect.left = 0;
rect.top = 0;
rect.right = 310;
rect.bottom = 67;
// Structure pour la brush
lb.lbStyle = BS_SOLID;
lb.lbColor = 0x00330000;
// On recupere le DC de la fenetre
hdcsound = BeginPaint(hwnd,&pssound);
hdcsoundtmp=CreateCompatibleDC(hdcsound);
hMemBmp= CreateCompatibleBitmap(hdcsound, 310,67);
hOldBmp= SelectObject(hdcsoundtmp, hMemBmp);
// Creation de BRUSH
hb = CreateBrushIndirect(&lb);
holdb = (HBRUSH)SelectObject(hdcsoundtmp, hb);
// On dessine le fond du scope
Rectangle(hdcsoundtmp, rect.left, rect.top, rect.right, rect.bottom);
hp1 = CreatePen(PS_SOLID, 1, 0x00DD7700);
holdp = (HPEN)SelectObject(hdcsoundtmp, hp1);
for(i=0; i<310; i++)
{
MoveToEx(hdcsoundtmp, i,rect.bottom-(6*beat[i]), NULL);
LineTo(hdcsoundtmp, i,rect.bottom-7);
if(sound[i]>min){
LineTo(hdcsoundtmp, i,rect.bottom-7-(((sound[i]-min)*60/(max-min))));
}
}
hp2 = CreatePen(PS_SOLID, 1, 0x00AA3300);
SelectObject(hdcsoundtmp, hp2);
if(moyenne<max)
{
MoveToEx(hdcsoundtmp, 0,rect.bottom-7-((moyenne-min)*60/(max-min)), NULL);
LineTo(hdcsoundtmp, 310,rect.bottom-7-((moyenne-min)*60/(max-min)));
}
hp3 = CreatePen(PS_SOLID, 1, 0x003300AA);
SelectObject(hdcsoundtmp, hp3);
if(seuilreel<max)
{if(seuilreel>min){
MoveToEx(hdcsoundtmp, 0,rect.bottom-7-((seuilreel-min)*60/(max-min)), NULL);
LineTo(hdcsoundtmp, 310,rect.bottom-7-((seuilreel-min)*60/(max-min)));
}}
hp4 = CreatePen(PS_SOLID, 1, 0x0055FFFF);
SelectObject(hdcsoundtmp, hp4);
if(moyenne+limithi<max)
{
MoveToEx(hdcsoundtmp, 0,rect.bottom-7-((moyenne+limithi-min)*60/(max-min)), NULL);
LineTo(hdcsoundtmp, 310,rect.bottom-7-((moyenne+limithi-min)*60/(max-min)));
}
if(moyenne+limitlow<max)
{
MoveToEx(hdcsoundtmp, 0,rect.bottom-7-((moyenne+limitlow-min)*60/(max-min)), NULL);
LineTo(hdcsoundtmp, 310,rect.bottom-7-((moyenne+limitlow-min)*60/(max-min)));
}
BitBlt(hdcsound,0,0,310,67,hdcsoundtmp,0,0,SRCCOPY);
// Fin du dessin
SelectObject(hdcsound, holdp);
SelectObject(hdcsound, holdb);
SelectObject(hdcsoundtmp, hOldBmp);
DeleteObject(hMemBmp);
DeleteDC(hdcsoundtmp);
DeleteObject(hp1);
DeleteObject(hp2);
DeleteObject(hp3);
DeleteObject(hp4);
DeleteObject(hb);
EndPaint(hwnd,&pssound);
return 0;
}
http://www.rc-bot.com