加载和释放
#include <atlimage.h>

int  captionHeight,  = 234;
CImage  consumeBkImg;       //分项能耗背景
consumeBkImg.Load(_T("res/server/consumeBk.jpg"));
consumeBkImg.Destroy();
//没有Destroy()会有内存泄漏。Detach();不行的。


//创建CImage,一般会在OnPaint()中,做双缓冲用。
CImage    fakeImge;
fakeImge.Create(consumeBkImg.GetWidth(), captionHeight, consumeBkImg.GetBPP());   //创建一个伪CImage做缓冲用
HDC fakeDC = fakeImge.GetDC();
CDC fakeCDC;
fakeCDC.Attach(fakeDC);

fakeCDC.Detach();
fakeImge.ReleaseDC();     //拿到的DC要释放,不释放第二次刷新会崩溃。
fakeImge.Destroy();

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
  • 2021-09-26
  • 2022-12-23
  • 2021-07-05
  • 2021-05-16
猜你喜欢
  • 2021-09-14
  • 2021-10-15
  • 2021-11-17
  • 2022-01-06
相关资源
相似解决方案