MFC如歌让图片自适应PictureControl大小 10
点击按钮加载图片,希望在源码上改voidCDrawCallDlg::OnBnClickedButton1(){CStatic*pWnd=(CStatic*)GetDlgI...
点击按钮加载图片,希望在源码上改
void CDrawCallDlg::OnBnClickedButton1()
{
CStatic* pWnd = (CStatic*)GetDlgItem(IDC_STATICS);
//设置静态控件窗口风格为位图居中显示
pWnd->ModifyStyle(0xf, SS_BITMAP | SS_CENTERIMAGE);
CImage image;
image.Load(_T("res\\pic0036.jpg"));
CBitmap* pBitmap = CBitmap::FromHandle(image);
pWnd->SetBitmap(*pBitmap);
} 展开
void CDrawCallDlg::OnBnClickedButton1()
{
CStatic* pWnd = (CStatic*)GetDlgItem(IDC_STATICS);
//设置静态控件窗口风格为位图居中显示
pWnd->ModifyStyle(0xf, SS_BITMAP | SS_CENTERIMAGE);
CImage image;
image.Load(_T("res\\pic0036.jpg"));
CBitmap* pBitmap = CBitmap::FromHandle(image);
pWnd->SetBitmap(*pBitmap);
} 展开
2个回答
展开全部
在对话框收到WM_SIZE时,先获取对话框的大小,然后改变picturebox的大小即可。
CRect rcClient,rcPicture;
GetClientRect(&rcClient);
m_PictureBox.GetClientRect(&rcPicture);
//禅逗燃 移动picturebox到对话指李框的左上角。
rcPicture.MoveToX(0);
rcPicture.MoveToY(0);
// pircurebox的长宽是对话框长宽的2分之1.
rcPicture.right = rcClient.Width() / 2;
rcPicture.bottom = rcClient.Height() / 2;
// 移贺虚动picturebox.
m_PictureBox.MoveWindow(rcPicture);
CRect rcClient,rcPicture;
GetClientRect(&rcClient);
m_PictureBox.GetClientRect(&rcPicture);
//禅逗燃 移动picturebox到对话指李框的左上角。
rcPicture.MoveToX(0);
rcPicture.MoveToY(0);
// pircurebox的长宽是对话框长宽的2分之1.
rcPicture.right = rcClient.Width() / 2;
rcPicture.bottom = rcClient.Height() / 2;
// 移贺虚动picturebox.
m_PictureBox.MoveWindow(rcPicture);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询