API 绘图


HWND hwnd=this->m_hWnd;
m_hDC = ::GetDC(hwnd);
m_hMemDC=CreateCompatibleDC(m_hDC);//创建兼容的内存设备描述表


       HBITMAP hbitmap=LoadBitmap(AfxGetApp()->m_hInstance,MAKETRESOURCE(IDB_BITMAP1);

CRect rect;
this->GetWindowRect(&rect);
InflateRect(rect,4,10);

HBRUSH hbr;
hbr= CreateSolidBrush(RGB(192,192,192)); //单色的画刷
FillRect(m_hMemDC,rect,m_hbr);

HBITMAP hOldBitmap =(HBITMAP) SelectObject(m_hMemDC, h bitmap.m_hObject);

BITMAP bm;

           GetObject (hbitmap, sizeof (BITMAP), &bm) ;

StretchBlt(m_hDC,m_bmpRect.left, m_bmpRect.top, m_bmpRect.Width()
, m_bmpRect.Height(), m_hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);   

SelectObject(m_hMemDC,hOldBitmap);

                DeleteObject(hbitmap);

DeleteObject(hOldBitmap);

DeleteObject(hbr);

               DeleteDC(m_hMemDC);
     ::ReleaseDC(this->m_hWnd,m_hDC);



你可能感兴趣的:(api)