我在类中定义了一些CDC,CBitmap的变量在Frame的派生类的构造函数中对图片进行初始化
CrunBallFrame::CrunBallFrame()
{
m_pdc_if=new CDC;
m_temp_dc=new CDC;
m_temp_bmp=new CBitmap; m_pbmp_if=new CBitmap;
m_pbmp_if->LoadBitmap(IDB_BITMAP1); m_pbmp_dish=new CBitmap;
m_pbmp_dish->LoadBitmap(IDB_BITMAP2); m_pbmp_ball=new CBitmap;
m_pbmp_ball->LoadBitmap(IDB_BITMAP3); m_pbmp_square=new CBitmap;
m_pbmp_square->LoadBitmap(IDB_BITMAP4);
}
OnPaint()函数的代码如下所示:void CrunBallFrame::OnPaint()
{
CPaintDC dc(this); m_pdc_if->CreateCompatibleDC(&dc);
m_temp_dc->CreateCompatibleDC(&dc);
m_temp_bmp->CreateCompatibleBitmap(&dc,538,329); m_pdc_if->SelectObject(m_temp_bmp); m_temp_dc->SelectObject(m_pbmp_if);
m_pdc_if->BitBlt(0,0,538,329,m_temp_dc,0,0,SRCCOPY);
m_temp_dc->SelectObject(m_pbmp_ball);
m_pdc_if->BitBlt(m_ball_x,m_ball_y,9,9,m_temp_dc,0,0,SRCCOPY);
m_temp_dc->SelectObject(m_pbmp_dish);
m_pdc_if->BitBlt(m_x_pos_dish,303,55,6,m_temp_dc,0,0,SRCCOPY);
for(int i=0;i<40;i++){
if(sInf[i].lock==1){
m_temp_dc->SelectObject(m_pbmp_square);
m_pdc_if->BitBlt(sInf[i].x,sInf[i].y,45,20,m_temp_dc,0,0,SRCCOPY);
}
}
dc.BitBlt(0,0,538,329,m_pdc_if,0,0,SRCCOPY);
m_temp_bmp->DeleteObject();
m_pdc_if->DeleteDC();
m_temp_dc->DeleteDC();
}我还定义了一个timer,会在100毫秒内调用Invalidate()函数进行从绘。我的代码还是会出现很严重的刷屏现象。请问我的问题出在哪里了,,我没有找到,谢谢:)
CrunBallFrame::CrunBallFrame()
{
m_pdc_if=new CDC;
m_temp_dc=new CDC;
m_temp_bmp=new CBitmap; m_pbmp_if=new CBitmap;
m_pbmp_if->LoadBitmap(IDB_BITMAP1); m_pbmp_dish=new CBitmap;
m_pbmp_dish->LoadBitmap(IDB_BITMAP2); m_pbmp_ball=new CBitmap;
m_pbmp_ball->LoadBitmap(IDB_BITMAP3); m_pbmp_square=new CBitmap;
m_pbmp_square->LoadBitmap(IDB_BITMAP4);
}
OnPaint()函数的代码如下所示:void CrunBallFrame::OnPaint()
{
CPaintDC dc(this); m_pdc_if->CreateCompatibleDC(&dc);
m_temp_dc->CreateCompatibleDC(&dc);
m_temp_bmp->CreateCompatibleBitmap(&dc,538,329); m_pdc_if->SelectObject(m_temp_bmp); m_temp_dc->SelectObject(m_pbmp_if);
m_pdc_if->BitBlt(0,0,538,329,m_temp_dc,0,0,SRCCOPY);
m_temp_dc->SelectObject(m_pbmp_ball);
m_pdc_if->BitBlt(m_ball_x,m_ball_y,9,9,m_temp_dc,0,0,SRCCOPY);
m_temp_dc->SelectObject(m_pbmp_dish);
m_pdc_if->BitBlt(m_x_pos_dish,303,55,6,m_temp_dc,0,0,SRCCOPY);
for(int i=0;i<40;i++){
if(sInf[i].lock==1){
m_temp_dc->SelectObject(m_pbmp_square);
m_pdc_if->BitBlt(sInf[i].x,sInf[i].y,45,20,m_temp_dc,0,0,SRCCOPY);
}
}
dc.BitBlt(0,0,538,329,m_pdc_if,0,0,SRCCOPY);
m_temp_bmp->DeleteObject();
m_pdc_if->DeleteDC();
m_temp_dc->DeleteDC();
}我还定义了一个timer,会在100毫秒内调用Invalidate()函数进行从绘。我的代码还是会出现很严重的刷屏现象。请问我的问题出在哪里了,,我没有找到,谢谢:)
解决方案 »
- char *cc="技师"与char ch[]="技师";char *cc=ch;有什么不同
- 请教大家文件流编程
- 请问一下,下面的代码有什么问题啊?
- 到别人的机器上用GDI+绘图出现“无法定位程序输入点GdiplusShutdown于动态链接库gdiplus.dll上”的警告。
- 为什么记录集一打开,就报出数据被截断的错误
- 请问direct show里为什么不能连入自己的库?
- 有没有通过网关发短信息的源代码?HELP!
- 有关二元信号量和信号量的区别
- 如何读取计算机中的chipset信息?
- 请教一个字体问题
- 请问有什么好的MP3播放类库或费的DLL?最好是国外的且易用的?谢谢!
- activeX控件内部能不能直接连接sql server,如何连?
另外,你的程序存在严重资源泄漏。