LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
  //HDC hdc = (HDC)wParam
  CPaintDC dc(m_hWnd);
  DoPaint(dc);
  
  bHandled = FALSE;  
  return 0;
 }

 void DoPaint(CPaintDC& dc)
 {

  CDCHandle _dc;
  HDC hdcDestop = ::GetDC(NULL);
  _dc.CreateCompatibleDC(hdcDestop);
  _dc.SelectBitmap(bitmap);

  
  
  dc.StretchBlt(rect.left, rect.top, rect.right, rect.bottom, _dc, 0, 0, 20, 20, SRCCOPY);

  ::ReleaseDC(NULL, hdcDestop);
  _dc.DeleteDC();
 }

 

如果此时 没有  _dc.DeleteDC(); 那么重新事件后 界面会成空白

 

 

dc使用原则.

Create用Delete

Get用Release

相关文章:

  • 2021-09-19
  • 2022-12-23
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
猜你喜欢
  • 2021-05-01
  • 2021-09-18
  • 2021-08-02
  • 2022-12-23
  • 2021-09-03
  • 2021-09-09
相关资源
相似解决方案