Not Ready Graphic GDI+

来源:互联网 发布:医院ap网络 编辑:程序博客网 时间:2024/06/14 05:37
CBitmap memBmp;
    CBitmap * pBmpOld = NULL;
    CFont * pOldFont = NULL;
    CPaintDC dc(this); // device context for painting
    CRect rectClient;
    GetClientRect( &rectClient );
    //dc.FillSolidRect(rectClient,RGB(211,211,211));
    dc.FillSolidRect(rectClient,RGB(255,255,255));

    CRect rect;
    GetClientRect(&rect);        

    CDC memDC;
    memDC.CreateCompatibleDC(&dc);
    memBmp.CreateCompatibleBitmap(&dc, rect.Width(), rect.Height());
    pBmpOld = memDC.SelectObject(&memBmp);

    Graphics graphics(memDC.GetSafeHdc());

    FontFamily fontFamily(L"宋体");
    Font font(&fontFamily, 11, FontStyleBold, UnitPoint);
    SolidBrush  solidBrush(Color(100,0,0,255));
    CString strTmp((LPCTSTR)IDS_GAGEER_STRING_SELFAN);
    graphics.DrawString(strTmp, (INT)wcslen(strTmp), &font, PointF(7, 7), &solidBrush);

    CString path;
    path = m_strCurrentDirectory + _T("\\模型 4-52");
    Image img(path.AllocSysString(), TRUE);
    graphics.DrawImage(&img, 200, 200, img.GetWidth(), img.GetHeight());
    
    dc.BitBlt(0,0, rect.Width(), rect.Height(), &memDC, 0, 0, SRCCOPY);

    memDC.SelectObject(pBmpOld);
    memBmp.DeleteObject();
    //删除兼容DC
    memDC.DeleteDC();
    ReleaseDC(&dc);