rainbowzc

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: :: :: 管理 ::

//改变窗口大小
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();

    }
}

posted on 2009-05-23 13:33  ct  阅读(485)  评论(0编辑  收藏  举报