MFC怎样清除picture control的图片?
需要加载多张图片,想要点击button1的时候在picturecontrol里显示图1,再点击button2加载图2,希望图2也显示在这个picturecontrol里,...
需要加载多张图片,想要点击button1的时候在picture control里显示图1,再点击button2加载图2,希望图2也显示在这个picture control里,覆盖原来的图1,picture control的ID为IDC_IMG。
void CImageStitchingDlg::OnBnClickedButton1()
{
CFileDialog opendlg (TRUE,_T("*"),_T("*.bmp"),OFN_OVERWRITEPROMPT, _T("所有文件(*.*;)|*.*||"),NULL);
if (opendlg.DoModal()==IDOK)
{
filename=opendlg.GetPathName();
}
HANDLE hHandle=::LoadImageW(NULL,filename,IMAGE_BITMAP,480,360,LR_LOADFROMFILE);
m_Picture.SetBitmap((HBITMAP)MAKEINTRESOURCE(hHandle));
}
void CImageStitchingDlg::OnBnClickedButton2()
{
CFileDialog opendlg (TRUE,_T("*"),_T("*.bmp"),OFN_OVERWRITEPROMPT, _T("所有文件(*.*;)|*.*||"),NULL);
if (opendlg.DoModal()==IDOK)
{
filename2=opendlg.GetPathName();
}
HANDLE hHandle=::LoadImageW(NULL,filename,IMAGE_BITMAP,480,360,LR_LOADFROMFILE);
m_Picture.SetBitmap((HBITMAP)MAKEINTRESOURCE(hHandle));
}
MFC新手,求教了,多谢! 展开
void CImageStitchingDlg::OnBnClickedButton1()
{
CFileDialog opendlg (TRUE,_T("*"),_T("*.bmp"),OFN_OVERWRITEPROMPT, _T("所有文件(*.*;)|*.*||"),NULL);
if (opendlg.DoModal()==IDOK)
{
filename=opendlg.GetPathName();
}
HANDLE hHandle=::LoadImageW(NULL,filename,IMAGE_BITMAP,480,360,LR_LOADFROMFILE);
m_Picture.SetBitmap((HBITMAP)MAKEINTRESOURCE(hHandle));
}
void CImageStitchingDlg::OnBnClickedButton2()
{
CFileDialog opendlg (TRUE,_T("*"),_T("*.bmp"),OFN_OVERWRITEPROMPT, _T("所有文件(*.*;)|*.*||"),NULL);
if (opendlg.DoModal()==IDOK)
{
filename2=opendlg.GetPathName();
}
HANDLE hHandle=::LoadImageW(NULL,filename,IMAGE_BITMAP,480,360,LR_LOADFROMFILE);
m_Picture.SetBitmap((HBITMAP)MAKEINTRESOURCE(hHandle));
}
MFC新手,求教了,多谢! 展开
1个回答
展开全部
CFileDialog opendlg (TRUE,_T(""),_T(""),OFN_OVERWRITEPROMPT, _T("位图文件(*.bmp;)|*.bmp||"),NULL);
if (opendlg.DoModal()==IDOK)
{
filename=opendlg.GetPathName();
HBITMAP hHandle=(HBITMAP)::LoadImage(NULL,filename,IMAGE_BITMAP,480,360,LR_LOADFROMFILE);
HBITMAP oldb = m_Picture.SetBitmap(hHandle);
DeleteObject(oldb);
}
来自:求助得到的回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询