这几天被资源泄漏整的很惨!!
CClientDC dc(this);
if(m_pMemDC->GetSafeHdc())
return FALSE;
if(!m_pMemDC->CreateCompatibleDC(&dc))
return FALSE;
CBitmap bmp;
if(!bmp.CreateCompatibleBitmap(&dc, m_rcClient.Width(), m_rcClient.Height()))
return FALSE;
//oldbitmap = (CBitmap*)m_pMemDC->SelectObject(bmp);
if(!m_pMemDC->SelectObject(bmp))
return FALSE;
//Set the background color of the control
CBrush bkBrush;
if(!bkBrush.CreateSolidBrush(m_crBackGround))
return FALSE;
m_pMemDC->FillRect(m_rcClient, &bkBrush);
//Select a specified pen to the device context to draw background lines
CPen bkLinesPen;
if(!bkLinesPen.CreatePen(PS_SOLID, 1, m_crGrids))
return FALSE;
//oldpen = (CPen*)m_pMemDC->SelectObject(bkLinesPen);
if(!m_pMemDC->SelectObject(bkLinesPen))
return FALSE;
//Draw background lines
for(register i = m_rcClient.left - 1; i < m_rcClient.right; i += 13)
{//画竖的网格线,间隔为13个象素
m_pMemDC->MoveTo(i, m_rcClient.top);
m_pMemDC->LineTo(i, m_rcClient.bottom);
}
for(register j = m_rcClient.top - 1; j < m_rcClient.bottom; j += 13)
{//画横的网格线,间隔为13个象素
m_pMemDC->MoveTo(m_rcClient.left, j);
m_pMemDC->LineTo(m_rcClient.right, j);
}
m_yPreviousPos = m_yPos = m_rcClient.bottom + 1;
InvalidateRect(m_rcClient);
return TRUE;
以上是我的一个函数里的程序,请问是不是有资源泄漏啊?该怎么处理?