关于 MFC 把 file 打开,然后在 picture control 里面显示的小程序片段
CImage image; //创建图片类
image.Load(strPath); //根据图片路径加载图片
CRect rect;//定义矩形类
int cx = image.GetWidth();//获取图片宽度
int cy = image.GetHeight();//获取图片高度
GetDlgItem(IDC_PICTURE)->GetWindowRect(&rect); //将窗口矩形选中到 picture 控件上
ScreenToClient(&rect);//将客户区选中到 Picture 控件表示的矩形区域内
GetDlgItem(IDC_PICTURE)->MoveWindow(rect.left,rect.top,cx,cy,TRUE);//将窗口移动
到 Picture 控件表示的矩形区域
CWnd *pWnd=GetDlgItem(IDC_PICTURE);//获得 pictrue 控件窗口的句柄
pWnd->GetClientRect(&rect);//获得 pictrue 控件所在的矩形区域
CDC *pDC=pWnd->GetDC();//获得 pictrue 控件的 DC
image.Draw(pDC->m_hDC, rect); //将图片画到 Picture 控件表示的矩形区域
ReleaseDC(pDC);//释放 picture 控件的 DC