WADrawDC.cpp 424 B

123456789101112131415161718192021222324252627282930313233
  1. #include "draw.h"
  2. #include "WADrawDC.h"
  3. WADrawDC::WADrawDC(HWND _hwnd)
  4. {
  5. hdc = draw_GetWindowDC(_hwnd);
  6. hwnd=_hwnd;
  7. }
  8. WADrawDC::WADrawDC(HDC _hdc, HWND _hwnd)
  9. {
  10. if (!_hdc)
  11. {
  12. hdc = draw_GetWindowDC(_hwnd);
  13. hwnd=_hwnd;
  14. }
  15. else
  16. {
  17. hdc=_hdc;
  18. hwnd=0; // set to 0 so we know not to call draw_ReleaseDC
  19. }
  20. }
  21. WADrawDC::~WADrawDC()
  22. {
  23. if (hwnd)
  24. draw_ReleaseDC(hwnd,hdc);
  25. }
  26. WADrawDC::operator HDC()
  27. {
  28. return hdc;
  29. }