//1.获取到桌面的路径
//2.拼接路径+文件名
//3.获取图片的高度和宽度
//4.将picture控件根据图片的高度和宽度进行重绘
//5.使用CDC类进行重新绘制
注:下列代码放在对话框的OnPaint()函数中
int cx, cy;
CImage image;
CRect rect;
//载入图片
TCHAR DeskPath[MAX_LENGTH] = "";
SHGetSpecialFolderPath(this->GetSafeHwnd(), DeskPath, CSIDL_DESKTOP, 0);
CString JpgPath = DeskPath;
JpgPath = JpgPath + "\\music.jpg";
image.Load(JpgPath);
//获取图片的高度和宽度
cx = image.GetWidth();
cy = image.GetHeight();
//获取picturt控件的大小
GetDlgItem(IDC_PICTURE)->GetWindowRect(&rect);
//选中的区域表示到控件中
ScreenToClient(&rect);
//窗口移动到表示的区域中
GetDlgItem(IDC_PICTURE)->MoveWindow(rect.left, rect.top, cx, cy, TRUE);
CWnd *pWnd = NULL;
pWnd = GetDlgItem(IDC_PICTURE);
pWnd->GetClientRect(&rect);
CDC *pDC = NULL;
pDC = pWnd->GetDC();
image.Draw(pDC->m_hDC, rect);
ReleaseDC(pDC);