怎样防止IPictur::Render盖住其他控件
我在对话框的OnInitDialog()中加载图片: pDC = this->GetDC();
CFile file;
if (!file.Open("E:\\1.jpg", CFile::modeRead|CFile::shareDenyWrite))
return FALSE;
CArchive ar(&file, CArchive::load | CArchive::bNoFlushOnDelete);
CArchiveStream arcstream(&ar);
IStream* pstm = (IStream*)&arcstream;
HRESULT hr = OleLoadPicture(pstm, 0, FALSE,
IID_IPicture, (LPVOID*)&pPic); ASSERT(SUCCEEDED(hr)); file.Close();
pPic->get_Width(&hmWidth);
pPic->get_Height(&hmHeight);
fX = pDC->GetDeviceCaps(HORZRES)*(int)hmWidth/((int)pDC->GetDeviceCaps(HORZSIZE)*100);
fY = pDC->GetDeviceCaps(VERTRES)*(int)hmHeight/((int)pDC->GetDeviceCaps(VERTSIZE)*100);
在OnPaint() 中绘制图片
if (IsIconic())
{
CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle
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; // Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
//画图
if(FAILED(pPic->Render(*pDC,0,0,(DWORD)fX,(DWORD) fY,0,hmHeight,hmWidth,-hmHeight,NULL)))
{
pPic->Release();
return;
}
}
但是对话框显示时,有时图片会盖住其他控件 比如 确定按键
如何才能让图片始终显示在最后面
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货