Nothing gets displayed on the picture control , why:
void CSchInfo::OnBnClickedButton1()
{
static TCHAR BASED_CODE szFilter[] = _T("Image Files (*.bmp;*.gif;*.jpg;*.png;*.tif)|*.bmp;*.gif;*.jpg;*.png;*.tif||");
CFileDialog FileDialog(TRUE,NULL,NULL,OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST,szFilter,this);
if(FileDialog.DoModal() == IDOK)
{
m_stLogoPath = FileDialog.GetPathName();
m_stFileName = FileDialog.GetFileName();
CWnd* pPicCtrl = GetDlgItem(IDC_STATIC13); CRect rc;
pPicCtrl->GetWindowRect(&rc);
Graphics graphics(pPicCtrl->GetDC()->GetSafeHdc());
Image image(m_stLogoPath);
graphics.DrawImage(&image,rc.TopLeft().x, rc.TopLeft().y,rc.Width(),rc.Height());
}
}
void CSchInfo::OnPaint()
{
CPaintDC dc(this);
if (IsIconic())
{
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
if(m_stLogoPath.GetLength())
{
CWnd* pPicCtrl = GetDlgItem(IDC_STATIC13);
CRect rc;
pPicCtrl->GetWindowRect(&rc);
Graphics graphics(pPicCtrl->GetDC()->GetSafeHdc());
Image image(m_stLogoPath);
graphics.DrawImage(&image,rc.TopLeft().x, rc.TopLeft().y,rc.Width(),rc.Height());
}
else if(m_stLogoPath1.GetLength())
{
CWnd* pPicCtrl = GetDlgItem(IDC_STATIC13);
CRect rc;
pPicCtrl->GetWindowRect(rc);
Graphics graphics(pPicCtrl->GetDC()->GetSafeHdc());
Image image(m_stLogoPath1);
graphics.DrawImage(&image,rc.TopLeft().x, rc.TopLeft().y,rc.Width(),rc.Height());
}
CDialog::OnPaint();
}
}
BEGIN_MESSAGE_MAP(CSchInfo, CDialogEx)
ON_COMMAND(IDC_BUTTON1,OnBnClickedButton1)
ON_COMMAND(IDOK,OnBnClickedOk)
ON_WM_PAINT()
END_MESSAGE_MAP()