19,520
社区成员




void CRamanDlg::OnPaint()
{
CRect rectClient, rectTemp;
CBitmap bitmapTemp, *pOldBitmap;
CDC dcMem;
CString strXcoordinate;
CString str;
CPaintDC dc(this);
CPoint ptStart1,ptEnd1,ptStart2,ptEnd2;
//Get client dailog Rectangle szie
GetClientRect(rectClient);
//create bitmap memory source
bitmapTemp.CreateCompatibleBitmap(&dc, rectClient.Width(), rectClient.Height());
dcMem.CreateCompatibleDC(&dc);//create compatible with dc
pOldBitmap = dcMem.SelectObject(&bitmapTemp);
dcMem.FillSolidRect(rectClient, RGB(0, 0, 0));
//get the border size
rectTemp.top = rectClient.top+30;
rectTemp.bottom = rectClient.bottom-40;
rectTemp.left = rectClient.left+130;
rectTemp.right = rectClient.right-25;
//设置坐标点
ptStart1.SetPoint(m_ptSx,rectTemp.top);
ptEnd1.SetPoint(m_ptSx,rectTemp.bottom);
ptStart2.SetPoint(m_ptEx,rectTemp.top);
ptEnd2.SetPoint(m_ptEx,rectTemp.bottom);
DrawCoordinate(&dcMem, rectTemp);
DrawSpectrum(&dcMem, rectTemp);
DrawLine(&dcMem,ptStart1,ptEnd1);
DrawLine(&dcMem,ptStart2,ptEnd2);
dc.BitBlt(0, 0, rectClient.Width(), rectClient.Height(), &dcMem, 0, 0, SRCCOPY);
//////////////////////////////////////////////////////////////////////////
GetMarkValue();
CString pty;
pty.Format(L"当前值:%.2f",m_Mark1);
//pty = L"当前值:"+pty;
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(RGB(255,0,0));
dc.ExtTextOut(rectClient.left+120,rectClient.top+245,ETO_CLIPPED,CRect(rectClient.left+120,rectClient.top+220,rectClient.left+270,rectClient.top+260),pty,NULL);//Set the coordinate disp pace
str.Format(L"平均值:%.2f",m_Mark2);
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(RGB(255,0,0));
dc.ExtTextOut(rectClient.left+10,rectClient.top+245,ETO_CLIPPED,CRect(rectClient.left+10,rectClient.top+220,rectClient.left+100,rectClient.top+260),str,NULL);
dcMem.SelectObject(pOldBitmap);
m_rectClient = rectClient;
strXcoordinate.Format(m_DispXUint);
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(RGB(0,0,255));
dc.ExtTextOut(rectClient.left+220,rectClient.top+245,ETO_CLIPPED,CRect(rectClient.left+220,rectClient.top+220,rectClient.left+360,rectClient.top+260),strXcoordinate,NULL);
CEdit *Rev_Text = (CEdit *)GetDlgItem(IDC_EDIT_REV);
Rev_Text->SetWindowText(m_strRecvData);
dcMem.DeleteDC();
InvalidateRect(rectClient,FALSE);
}