主题:[讨论]BltBit()函数的使用问题
在文档视图中
我在OnDraw()中添加如下代码
CBitmap bmp,*poldbmp;
GetClientRect(&m_rectClient);
CPen pen(PS_SOLID,1,RGB(255,0,0)),*pOld;
CBrush bkbrush(RGB(255,255,0));
/* CDC memDC;
memDC.CreateCompatibleDC(pDC);
membmp.CreateCompatibleBitmap(pDC,m_rectClient.Width(),m_rectClient.Height());
poldbmp=(CBitmap *)memDC.SelectObject(&membmp);*/
if(m_MemDC.GetSafeHdc()==NULL)
{
m_MemDC.CreateCompatibleDC(pDC);
//
//memDC->BitBlt(
bmp.CreateCompatibleBitmap(pDC,m_rectClient.Width(),m_rectClient.Height());
poldbmp=m_MemDC.SelectObject(&bmp);
pOld=m_MemDC.SelectObject(&pen);
m_MemDC.SetBkColor(RGB(0,0,0));
//m_MemDC.MoveTo(450,400);
//m_MemDC.LineTo(470,300);
m_MemDC.FillRect(m_rectClient,&bkbrush);
m_MemDC.BitBlt(0,0,m_rectClient.Width(),m_rectClient.Height(),&m_MemDC,10,0,SRCCOPY);
pDC->BitBlt(0,0,m_rectClient.Width(),m_rectClient.Height(),&m_MemDC,0,0,SRCCOPY);
bmp.DeleteObject();
m_MemDC.SelectObject(poldbmp);
m_MemDC.SelectObject(pOld );
//memDC->DeleteDC();
m_MemDC.DeleteDC();
}
else
{
m_MemDC.TextOut(100,100,"dfasdfsd");
pDC->BitBlt(0,0,m_rectClient.Width(),m_rectClient.Height(),&m_MemDC,0,0,SRCCOPY);
}
还添加个定时器,每一秒重画,怎么m_MemDC.TextOut();没有运行,没有显示出来。
我在OnDraw()中添加如下代码
CBitmap bmp,*poldbmp;
GetClientRect(&m_rectClient);
CPen pen(PS_SOLID,1,RGB(255,0,0)),*pOld;
CBrush bkbrush(RGB(255,255,0));
/* CDC memDC;
memDC.CreateCompatibleDC(pDC);
membmp.CreateCompatibleBitmap(pDC,m_rectClient.Width(),m_rectClient.Height());
poldbmp=(CBitmap *)memDC.SelectObject(&membmp);*/
if(m_MemDC.GetSafeHdc()==NULL)
{
m_MemDC.CreateCompatibleDC(pDC);
//
//memDC->BitBlt(
bmp.CreateCompatibleBitmap(pDC,m_rectClient.Width(),m_rectClient.Height());
poldbmp=m_MemDC.SelectObject(&bmp);
pOld=m_MemDC.SelectObject(&pen);
m_MemDC.SetBkColor(RGB(0,0,0));
//m_MemDC.MoveTo(450,400);
//m_MemDC.LineTo(470,300);
m_MemDC.FillRect(m_rectClient,&bkbrush);
m_MemDC.BitBlt(0,0,m_rectClient.Width(),m_rectClient.Height(),&m_MemDC,10,0,SRCCOPY);
pDC->BitBlt(0,0,m_rectClient.Width(),m_rectClient.Height(),&m_MemDC,0,0,SRCCOPY);
bmp.DeleteObject();
m_MemDC.SelectObject(poldbmp);
m_MemDC.SelectObject(pOld );
//memDC->DeleteDC();
m_MemDC.DeleteDC();
}
else
{
m_MemDC.TextOut(100,100,"dfasdfsd");
pDC->BitBlt(0,0,m_rectClient.Width(),m_rectClient.Height(),&m_MemDC,0,0,SRCCOPY);
}
还添加个定时器,每一秒重画,怎么m_MemDC.TextOut();没有运行,没有显示出来。