CDC *pPicDC;
CPen *pPen = new CPen(PS_SOLID, 2, RGB(0, 0, 0));
int iCounter;
float fStep;
CHANNEL_HANDLE hChannel; // <-- das wirst Du nicht brauchen, da Deine Meßwerte woanders herkommen
LOGBRUSH logbrush;
CBrush brushErase;
CBrush brushPaint;
CRect rectPaint;
CRgn rgnPaint;
CRect rectWinRect, rectPictureRect, rectPicCoord;
//... anderer Code ...
pPicDC = m_staticGraphOut.GetDC(); // <-- hier den DC Deines Fensters ermitteln!!
m_staticGraphOut.GetClientRect(&rectPaint);
rgnPaint.CreateRectRgnIndirect(&rectPaint);
pPicDC->SelectClipRgn(&rgnPaint);
pPicDC->SetBkColor(RGB(255, 255, 255));
pPicDC->SetBkMode(TRANSPARENT);
pPicDC->SetTextAlign(TA_LEFT | TA_BASELINE);
logbrush.lbStyle = BS_SOLID;
logbrush.lbColor = RGB(255, 255, 255);
brushErase.CreateBrushIndirect(&logbrush);
logbrush.lbStyle = BS_HOLLOW;
brushPaint.CreateBrushIndirect(&logbrush);
m_staticGraphOut.GetWindowRect(&rectPictureRect);
GetWindowRect(&rectWinRect);
rectPicCoord.left = (rectPictureRect.left - rectWinRect.left) - 1;
rectPicCoord.top = (rectPictureRect.top - rectWinRect.top) - 1;
rectPicCoord.right = (rectPictureRect.right - rectWinRect.left) - 3;
rectPicCoord.bottom = (rectPictureRect.bottom - rectWinRect.top) - 3;
//Zeichenfläche löschen
pPicDC->SelectObject(&brushPaint);
pPicDC->FillRect(rectPaint, &brushErase);
//Achsen zeichnen
pPicDC->SelectObject(pPen);
pPicDC->SetMapMode(MM_TEXT);
pDC->SelectObject(pPen);
pDC->SetMapMode(MM_TEXT);
//Y-Achse
fStep = (float)rectPicCoord.Height() / (float)Y_AXIS_DIFF;
for(iCounter = 0; iCounter < Y_AXIS_DIFF; iCounter++)
{
pDC->MoveTo(rectPicCoord.left - 5, rectPicCoord.top + (int)((float)iCounter * fStep));
pDC->LineTo(rectPicCoord.left, rectPicCoord.top + (int)((float)iCounter * fStep));
}
pDC->MoveTo(rectPicCoord.left - 5, rectPicCoord.bottom);
pDC->LineTo(rectPicCoord.left, rectPicCoord.bottom);
//X-Achse
fStep = (float)rectPicCoord.Width() / (float)X_AXIS_DIFF;
for(iCounter = 0; iCounter < X_AXIS_DIFF; iCounter++)
{
pDC->MoveTo(rectPicCoord.left + (int)((float)iCounter * fStep), rectPicCoord.bottom);
pDC->LineTo(rectPicCoord.left + (int)((float)iCounter * fStep), rectPicCoord.bottom + 5);
}
pDC->MoveTo(rectPicCoord.right, rectPicCoord.bottom);
pDC->LineTo(rectPicCoord.right, rectPicCoord.bottom + 5);
//Kurven
m_staticGraphOut.GetClientRect(&rectPictureRect);
pPicDC->SetViewportOrg(0, rectPaint.bottom / 2);
hChannel = m_pDoc->GetFirstChannelHandle(); // <-- jeder Channel ist ein Meßkanal
while(hChannel != NULL)
{
int iVal, iMaxVal, iMinVal, iCenter, iDiff;
float fXPos = 0.0f;
BOOL bHasValue;
CString Name;
pPen->DeleteObject();
pPen->CreatePen(PS_SOLID, 1, m_pDoc->GetChannelColor(hChannel));
pPicDC->SelectObject(pPen);
m_fXStep = (float)rectPaint.Width() / (float)m_pDoc->GetChannelBufferSize(hChannel);
iMaxVal = m_pDoc->GetChannelMaxValue(hChannel);
iMinVal = m_pDoc->GetChannelMinValue(hChannel);
iCenter = (iMaxVal + iMinVal) / 2;
iDiff = iMaxVal - iMinVal;
m_fYStep = (float)rectPaint.Height() / (float)iDiff;
if(iMinVal == 0) iMinVal = (int)(-1.0 / m_fYStep);
pPicDC->SetViewportOrg(0, (int)((float)rectPaint.Height() + (float)iMinVal * m_fYStep));
bHasValue = m_pDoc->GetFirstChannelValue(hChannel, iVal);
//1. Punkt
if(bHasValue)
{
pPicDC->MoveTo(0, (int)-((float)iVal * m_fYStep));
bHasValue = m_pDoc->GetNextChannelValue(hChannel, iVal);
}
//weitere Punkte
while(bHasValue)
{
fXPos += m_fXStep; / <-- konstanter Abstand in X-Richtung
pPicDC->LineTo((int)fXPos, (int)-((float)iVal * m_fYStep));
bHasValue = m_pDoc->GetNextChannelValue(hChannel, iVal);
}
hChannel = m_pDoc->GetNextChannelHandle(hChannel);
}
m_staticGraphOut.ValidateRect(NULL);
delete pPen;