15,979
社区成员
发帖
与我相关
我的任务
分享
void CdlgPlayerWnds::OnPaint()
{
CPaintDC dc(this);
RECT rect;
SetParent(CWnd::FromHandle(m_hwndOld));
GetParent()->GetClientRect(&rect);//获取窗口大小信息
CDC mdc,bufdc;
HBITMAP bmp;
mdc.CreateCompatibleDC(&dc);
bufdc.CreateCompatibleDC(&dc);
bmp=CreateCompatibleBitmap(dc.GetSafeHdc(),rect.right,rect.bottom);
mdc.SelectObject(&bmp);
m_hBmpNoVedio=(HBITMAP)LoadImage(NULL,"./res/nobmp.bmp",IMAGE_BITMAP,900,600,LR_LOADFROMFILE);//从文件导入位图
BITMAP bmInfo;
GetObject(m_hBmpNoVedio,sizeof(BITMAP),(LPBYTE)&bmInfo); //得到图片尺寸
bufdc.SelectObject(&m_hBmpNoVedio);
mdc.StretchBlt(0,0,rect.right,rect.bottom,&bufdc,0,0,bmInfo.bmWidth,bmInfo.bmHeight,SRCCOPY);
dc.BitBlt(0,0,rect.right,rect.bottom,&bufdc,0,0,SRCCOPY);
}