// DlgIndicator.cpp: 实现文件 // #include "mem_dc.h" ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // compatible_dc compatible_dc::compatible_dc(HDC src) : src_(src), old_(NULL) { HWND hwnd = WindowFromDC(src); RECT r = { 0 }; if (!IsWindow(hwnd)) hwnd = GetDesktopWindow(); GetWindowRect(hwnd, &r); size_.cx = r.right - r.left; size_.cy = r.bottom - r.top; bmp_ = CreateCompatibleBitmap(src, size_.cx, size_.cy); hdc_ = CreateCompatibleDC(src); old_ = (HBITMAP)SelectObject(hdc_, bmp_); BitBlt(hdc_, 0, 0, size_.cx, size_.cy, src, 0, 0, SRCCOPY); } compatible_dc::~compatible_dc() { BitBlt(src_, 0, 0, size_.cx, size_.cy, hdc_, 0, 0, SRCCOPY); SelectObject(hdc_, old_); DeleteObject(bmp_); DeleteDC(hdc_); } HDC compatible_dc::get_dc() { return hdc_; }