1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| void CMyApp::DrawLongitudinalAxis(CStatic* area,int min,int max,char nbraxis)
{
CDC* ChartCDC; //Déclaration d'un Device Context
CRect ChartRect;//Déclaration d'un rectangle englobant
CPen aPen; //Déclaration d'une plume
CString Etiquette;//Déclaration d'une variable de type String
area->Invalidate(TRUE);
ChartCDC = area->GetDC(); //Affectation de la zone de dessin à la variable ChartCDC
area->GetClientRect(&ChartRect); //Affectation du rectangle englobant du graphique à la variable area
ChartRect.DeflateRect(1,1);
ChartCDC->SetBkMode(TRANSPARENT);
ChartCDC->SetTextAlign(TA_LEFT);
aPen.CreatePen(PS_DASHDOT,1,RGB(255,0,0));
CPen *pOldPen=ChartCDC->SelectObject(&aPen);
ChartCDC->MoveTo(0,ChartRect.Height()-5*(ChartRect.Height()/(nbraxis-1)));
ChartCDC->LineTo(ChartRect.Width(),ChartRect.Height()-5*(ChartRect.Height()/(nbraxis-1)));
Etiquette.Format("%.0f",(float)5*(max-min)/(nbraxis-1)+min);
ChartCDC->TextOut(0,ChartRect.Height()-5*(ChartRect.Height()/(nbraxis-1))-7,Etiquette);
ChartCDC->SelectObject(&pOldPen); // déselection = selection de l'ancien stylo
aPen.DeleteObject();
// ChartCDC->ReleaseOutputDC(); <<==Sans effets sur la libération d'espace mémoire
// area->ReleaseDC(ChartCDC); <<==Pareil
ReleaseDC(ChartCDC); //Çà apparemment çà marche !
} |
Partager