16,472
社区成员
发帖
与我相关
我的任务
分享
void CPROJECTView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect rect;
GetClientRect(rect);
GetDlgItem(IDC_OSCOPE)->MoveWindow(rect); //承载绘图类的空间
m_OScopeCtrl.m_rectClient.right = rect.right;
m_OScopeCtrl.m_rectClient.bottom = rect.bottom;
m_OScopeCtrl.m_rectPlot.right = rect.right-20;
m_OScopeCtrl.m_rectPlot.bottom = rect.bottom-60;
m_OScopeCtrl.InvalidateCtrl();
// Do not call CFormView::OnPaint() for painting messages
}
void COScopeCtrl::OnPaint()
{
CPaintDC dc(this) ; // device context for painting
CDC memDC ;
CBitmap memBitmap ;
CBitmap* oldBitmap ; // bitmap originally found in CMemDC
// no real plotting work is performed here,
// just putting the existing bitmaps on the client
// to avoid flicker, establish a memory dc, draw to it
// and then BitBlt it to the client
memDC.CreateCompatibleDC(&dc) ;
memBitmap.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight) ;
oldBitmap = (CBitmap *)memDC.SelectObject(&memBitmap) ;
if (memDC.GetSafeHdc() != NULL)
{
// first drop the grid on the memory dc
memDC.BitBlt(0, 0, m_nClientWidth, m_nClientHeight,
&m_dcGrid, 0, 0, SRCCOPY) ;
// now add the plot on top as a "pattern" via SRCPAINT.
// works well with dark background and a light plot
memDC.BitBlt(0, 0, m_nClientWidth, m_nClientHeight,
&m_dcPlot, 0, 0, SRCPAINT) ; //SRCPAINT
// finally send the result to the display
dc.BitBlt(0, 0, m_nClientWidth, m_nClientHeight,
&memDC, 0, 0, SRCCOPY) ;
}
memDC.SelectObject(oldBitmap) ;
}
这是下载的类的OnPaint函数