zoukankan      html  css  js  c++  java
  • MFC GDI编程注意事项

    //改变窗口大小
    CRect rect;

    GetWindowRect(&rect);
    AfxGetMainWnd()->MoveWindow(0,0,800,400,1);
    AfxGetMainWnd()->CenterWindow();

     


    //CString到WChar的转换
    CString cstr;
    WChar wch[200];
    wcscpy(wch,cstr.AllocSysString());

     


    //error C2660: “Gdiplus::GdiplusBase::operator new” : 函数不接受3个参数
    //if(BitmapL==0) BitmapL = new Bitmap(GleftFile);
    //需要在new前加::

    if(BitmapL==0) BitmapL = ::new Bitmap(GleftFile);

     


    //在窗口中绘制图片
    //图片路径为str_picPath,根据当前窗口rect绘制
    CRect rect;
    GetClientRect(&rect);


    HANDLE filehandle=LoadImage(NULL,str_picPath,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
    if(filehandle!=NULL)
     
        CBitmap bmp;

        if(bmp.Attach(filehandle))  
        
            BITMAP bmpInfo;  
            bmp.GetBitmap(&bmpInfo);  
            CDC dcMemory;  
            dcMemory.CreateCompatibleDC(pDC);
            dcMemory.SelectObject(&bmp);
         // pDC->SetStretchBltMode(HALFTONE);
            pDC->StretchBlt(0,0,rect.Width(),rect.Height(),&dcMemory,0,0,bmpInfo.bmWidth,bmpInfo.bmHeight,SRCCOPY);  
            bmp.Detach();

        }
    }

  • 相关阅读:
    Examples
    Examples
    Examples
    Examples
    Examples
    Examples
    Examples
    Examples
    Examples
    如何把随机数或者对象添加到ArrayList集合
  • 原文地址:https://www.cnblogs.com/rainbowzc/p/1487629.html
Copyright © 2011-2022 走看看